Skip to content

Commit 486db78

Browse files
Testclaude
andcommitted
chore(skill): add infection-stats.php to mutation-analyzer skill
Replaces ad-hoc `grep | awk` / `grep | sed` pipelines that kept tripping the permission allow-list on every Infection analysis with a single PHP script that reads the three text artefacts (infection-summary.log, per-mutator.md, infection.log) and exposes four modes: --summary counts + MSI --by-file [--top] escapes per src/ file, sorted --by-mutator per-mutator.md compact list (with --escaped-only) --filter=<needle> mutants whose path contains the needle, with L<n> pointing at the log line so the orchestrator can Read offset=L<n> limit=15 to inspect the diff php8.4:* is already on the allow-list, so the script never prompts for permissions. SKILL.md is updated to use the script as the default flow and to call out that ad-hoc grep/sed pipelines should NOT be composed for these counts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7a9a310 commit 486db78

2 files changed

Lines changed: 370 additions & 17 deletions

File tree

.claude/skills/mutation-analyzer/SKILL.md

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,31 @@ Infection escribe en `reports/infection/`. **Usa sólo los tres ficheros de text
3939

4040
**Flujo de lectura:**
4141

42-
1. `Read reports/infection/infection-summary.log` → conocer volumen.
43-
2. `Read reports/infection/per-mutator.md` → ver qué tipos de mutator dominan (orienta la priorización).
44-
3. `Grep` sobre `reports/infection/infection.log` para extraer los mutants de un módulo/fichero concreto con su número de línea en el log:
45-
```
46-
Grep pattern:"^\d+\) /abs/path/src/Modulo/" path:"reports/infection/infection.log" output_mode:"content" -n:true
47-
```
48-
4. `Read reports/infection/infection.log` con `offset`/`limit` sobre los rangos que te interesen.
42+
Usar **siempre** el script `scripts/infection-stats.php` para los conteos y el perfilado por fichero/mutator. Está pensado para reemplazar pipelines `grep | awk` / `grep | sed` ad-hoc que rompen permisos y son frágiles. Sólo recurrir a `Grep` + `Read` cuando se quiera leer el diff completo de un mutant concreto.
43+
44+
```bash
45+
# 1. Volumen + MSI (primer vistazo)
46+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --summary
47+
48+
# 2. Mutators dominantes con escapes (orienta priorización)
49+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --by-mutator --escaped-only
50+
51+
# 3. Ficheros con más escapes (orienta orden de análisis)
52+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --by-file --top=15
53+
54+
# 4. Lista detallada de mutants de un fichero (con la línea del log para abrirla con Read)
55+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --filter=src/Execution/FlowExecutor.php
56+
57+
# 5. Lo mismo pero para timeouts
58+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --filter=src/Execution/FlowExecutor.php --section=timeout
59+
```
60+
61+
`--filter` imprime una línea por mutant con `L<n>` (línea del log), índice, path, mutator, ID. Usa el `L<n>` como `offset` para leer el diff con `Read`:
62+
63+
```
64+
L552 43) /var/www/html1/src/Execution/FlowExecutor.php:286 Continue_ f4ef6cc1...
65+
→ Read reports/infection/infection.log offset=552 limit=15
66+
```
4967

5068
**Nunca usar** `Read` sobre `mutation-report.html` — romperá el límite de mensaje y no añade información sobre los `.log`/`.md`. Si el usuario lo adjunta, recordárselo y pedir que aporte el `infection.log` o que re-ejecute Infection acotado (ver abajo).
5169

@@ -152,21 +170,29 @@ CRUZADO no infla las métricas de Infection (el mutante seguirá vivo o lo mata
152170

153171
### Paso 1 — Resumen y perfil (los tres ficheros de texto)
154172

155-
1. **Volumen total**`Read reports/infection/infection-summary.log` (siempre pequeño, no necesita offset/limit):
173+
Ejecutar el script `scripts/infection-stats.php` para los tres conteos básicos. Sustituye lo que antes eran 3 invocaciones de `Grep`/`Read` con post-proceso manual:
174+
175+
```bash
176+
# Volumen total + MSI
177+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --summary
156178

157-
```
158-
Total / Killed / Escaped / Timeouts / MSI
159-
```
179+
# Mutators dominantes con escapes
180+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --by-mutator --escaped-only
160181

161-
2. **Mutators dominantes**`Read reports/infection/per-mutator.md`. Identifica patrones: si `LogicalOr` concentra 40 escapes, sabes que hay un patrón de guards defensivos repetido.
182+
# Ficheros con más escapes (orienta orden de análisis)
183+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --by-file --top=15
184+
```
162185

163-
3. **Ficheros afectados** — sobre `infection.log`:
186+
Cuando se quiera bajar al detalle de un módulo concreto:
164187

165-
```
166-
Grep pattern:"^\d+\) /var/www/html[0-9]*/src/" path:"reports/infection/infection.log" output_mode:"content" -n:true
167-
```
188+
```bash
189+
# Lista de mutants en un fichero (con la L<n> que apunta a la línea del log)
190+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --filter=src/Execution/FlowExecutor.php
191+
# Para timeouts:
192+
php8.4 .claude/skills/mutation-analyzer/scripts/infection-stats.php --filter=src/Execution/FlowExecutor.php --section=timeout
193+
```
168194

169-
Devuelve `línea_log:índice) path:línea Mutator`. Guardar los rangos de líneas del log por módulo para agentes paralelos.
195+
Y luego `Read reports/infection/infection.log offset=L<n> limit=15` para inspeccionar el diff exacto. **No** componer `grep | sed`/`awk` ad-hoc — rompe permisos y es frágil.
170196

171197
**Nunca abrir `mutation-report.html`**: es HTML de 5-10 MB con CSS/JS embebidos; rompe el límite de mensaje y no aporta sobre los `.log`/`.md`.
172198

0 commit comments

Comments
 (0)