README.md
# Test Report Analyst (AgentRove native agent)
`agentrove.test-report-analyst` 0.1.2 · MIT · Node.js >= 20 · no npm dependencies · no network
Published by AgentRove (provisional, configurable name). Package identifiers keep the agentrove prefix for compatibility.
Reads the test result and coverage files your own test runs already produced and tells you what
matters: which suites failed, the failures with the first lines of their messages, the slowest tests,
what changed since the previous run (new failures, fixes, flaky candidates) and which files have the
most uncovered lines. It **never runs tests, commands or code**, makes no network requests, and only
reads files inside your workspace folder. The single write is `write_report`, which saves a report as
one new file after you confirm.
## Tools
| Tool | Side effects | What it does |
| --- | --- | --- |
| `summarize_results` | none (reads files) | One run from JUnit XML, TAP or Jest/Vitest JSON files (`paths`: files or globs) or `results_text`: status, totals, pass/fail/error/skip/todo per suite, slowest tests, failures with the first `message_lines` (default 5) lines of their messages, tests that passed only after a retry, per-file parse status, warnings and a Markdown `report`. |
| `compare_runs` | none (reads files) | `base` and `head` runs: new failures, fixed, still failing, new and removed tests, tests at least 1.5x and 100 ms slower, and **flaky candidates**. |
| `coverage_report` | none (reads files) | lcov (`lcov.info`): line, function and branch coverage per file, uncovered-line counts and ranges (`9, 20-22`), totals, files below an optional `threshold`, sorted by uncovered lines, coverage or path. Repeated records for the same file are merged. |
| `write_report` | **writes local files** (confirmation required) | Saves text (for example another tool's `report`) as one new `.md`, `.markdown`, `.txt` or `.json` file **inside `reports/`**. Never replaces an existing file (`if_exists: "suffix"` picks `name-2.md`, ...), never uses an instruction or configuration file name, never writes through links, creates missing folders inside `reports/` only, deletes nothing. |
### Formats
- **JUnit XML**: `<testsuites>` / `<testsuite>` / `<testcase>` with `<failure>`, `<error>`, `<skipped>`;
nested suites (PHPUnit); Surefire `flakyFailure` / `rerunFailure` (a test that passed after a
rerun is listed as flaky within the run). Produced by Maven/Gradle, pytest `--junitxml`, Vitest and
Jest junit reporters, go-junit-report and others.
- **TAP** 13/14 including node:test subtests (a subtest's summary line becomes its suite, not an
extra test), `# SKIP`, `# TODO`, YAML diagnostics (`duration_ms`, `error`/`message`), `Bail out!`.
- **Jest / Vitest JSON** (`--json`, `--reporter=json`): `testResults[].assertionResults[]`, nested
`describe` names joined with `>`, a test file that failed to load becomes one `error` entry.
- **lcov** (`coverage_report` only).
- Format is detected from the extension, then the content; set `format` to override. UTF-8 and
UTF-16 with a byte-order mark (Windows PowerShell 5.1 writes UTF-16 by default) are read.
- Absolute paths inside reports are shortened to their common folder (keeping its last part, e.g.
`src/price.test.ts`), so runs from different machines can be compared. Tests are matched by suite
and name, then by file name and name when that is unique.
### Flaky candidates
A flaky candidate is a test that
1. changed between passing and failing although `changed_files` says nothing changed between the two
runs (pass `"changed_files": []` for two runs of the same code), or
2. passed and failed within one run (a reported rerun or retry, or repeated entries with different
results).
When `changed_files` is omitted (unknown), status changes are reported only as new failures or fixes,
with a warning. A candidate is a hint to re-run or investigate, not proof.
## Safety
- **Safe XML**: a small built-in parser; any `<!DOCTYPE>` or `<!ENTITY>` declaration is refused, so no
entity is defined or expanded ("billion laughs") and no external file or URL is loaded (XXE). Only
`< > & " '` and numeric references are decoded; other `&name;` stays text.
Element count (500,000), depth (64) and attributes per element (100) are limited.
- **Workspace** (security review finding C6, 0.1.1): `AGENTROVE_TEST_REPORTS_ROOT` if set; otherwise
the folder the CLI or MCP server was started in, **only if it looks like a project** (it contains
`.git`, `package.json`, `pyproject.toml`, `go.mod`, `Cargo.toml`, `pom.xml`, `build.gradle`,
`CLAUDE.md`, `.claude`, `.mcp.json` or a similar marker, or an empty `.agentrove-workspace` file you
add); otherwise it fails with `workspace_not_chosen`. A drive or file-system root, your home folder
itself, the folder holding the home folders, and system folders are always refused. Same path rules
as workflow-automation: relative paths only, no `..`, drive letters, UNC paths, `:`, reserved names,
Windows 8.3 short names (`ENV~1`) or hidden names (`.git`, `.env`); reads follow links only when they
end inside the workspace; listings skip links; writes refuse links on the path.
- **Reports folder and protected names** (security review finding C5, 0.1.1): `write_report` writes only
inside `reports/` and never uses a name that AI assistants, MCP clients or tools read as instructions
or configuration (`CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `SKILL.md`, `*.instructions.md`,
`*.prompt.md`, `llms.txt`, `mcp.json`, `settings.json`, `package.json`, `tsconfig.json`,
`*.config.json`, anything under `node_modules/` or `.claude/` and similar, in any letter case), so a
confirmed write cannot plant persistent instructions for a coding assistant.
- **Limits**: 20 MB per file by default (`max_file_bytes`, at most 50 MB), 100 MB read per call, 200
files per run, 200,000 test results, 60 s per call, 20 MB `results_text`, 5 MB reports. A file that
is too large, malformed or unsafe is listed in `files` with the reason and makes the result
`complete: false`; the other files are still analysed.
- **Untrusted content**: test names, messages and paths are data. They are truncated and quoted;
the Markdown report escapes them and puts failure messages in code blocks whose fence is longer than
any fence inside the message, so a message cannot add headings, links or instructions to the report.
## Usage (Node CLI)
```sh
node bin/cli.js --help
node bin/cli.js summarize_results --json '{"paths": ["reports/junit/*.xml"]}'
node bin/cli.js compare_runs --input compare.json # {"base": {"paths": ["ci/main/*.xml"]}, "head": {"paths": ["ci/pr/*.xml"]}, "changed_files": []}
node bin/cli.js coverage_report --json '{"paths": ["coverage/lcov.info"], "threshold": 80}'
node bin/cli.js write_report --input save.json # {"path": "reports/test-summary.md", "content": "<report>", "confirm": true}
```
Run the CLI in your project folder (one with `.git`, `package.json` or a similar marker), or set
`AGENTROVE_TEST_REPORTS_ROOT`. On Windows PowerShell,
prefer `--input file.json` over `--json` quoting.
## Use as an MCP server
```sh
claude mcp add test-report-analyst -- node /absolute/path/to/test-report-analyst/bin/mcp.js
```
The server's start folder is the workspace if it looks like a project; otherwise set
`AGENTROVE_TEST_REPORTS_ROOT` in the server's environment.
`claude-code/SKILL.md` is a Claude Code skill that drives the CLI.
## Typed IO (composition)
- Inputs: `results_text` (`text`) for `summarize_results` / `coverage_report`, and `content`
(`markdown_document`) for `write_report`.
- Output: `report` (`markdown_document`) from the three analysis tools.
## Testing status
- Node.js (Vitest): `tests/test-report-analyst.test.ts` with synthetic fixtures in `tests/fixtures`:
JUnit (including a Surefire rerun), Vitest JSON, node:test TAP, lcov, UTF-16 input, malformed and
truncated XML, DOCTYPE/ENTITY expansion and external-entity attempts, oversized files, path
traversal, link escapes (junctions on Windows), a prompt-injection failure message, the CLI and MCP
stdio.
- Also checked against reports generated locally by Vitest 5 (`junit` and `json` reporters) and by
Node.js 24 `node --test` (`tap` and `lcov` reporters).
- Tested on Windows 11 (NTFS) with Node.js 24. macOS and Linux have not been tested by AgentRove.
- Runs inside AI clients (Claude Code, Codex and others) are recorded separately for each version on this
agent's page on the AgentRove site; this file is written before those runs, so it states none.
## Limitations
- Reads only what the reports contain: it cannot tell why a test failed beyond its message, and
durations are whatever the reporter recorded. Without `changed_files` it cannot separate flaky
tests from real regressions.
- No Cobertura, Clover, JaCoCo or Istanbul JSON coverage (lcov only); no TRX, xUnit.net v2, NUnit 3 or
Allure formats yet; JUnit dialects vary and unusual ones may lose details (unknown elements are
ignored).
- No history beyond the two runs you pass; no trend storage.