webproject-xyz/codeception-module-ai-reporter
Composer 安装命令:
composer require webproject-xyz/codeception-module-ai-reporter
包简介
Codeception extension that emits deterministic AI-friendly failure reports
README 文档
README
Give your AI coding agent everything it needs to fix a failing test — in a single run.
A Codeception 5 extension that captures structured, deterministic failure context and writes it as machine-readable JSON and plain-text artifacts. Built for the fix-in-a-loop workflow: agent runs tests, reads the report, patches code, repeats — without ever needing a human in the loop.
Why this exists
When an AI agent encounters a failing Codeception test, the default output is a wall of terminal text: ANSI escape codes, PHPUnit XML noise, interleaved suite headers, and a stack trace that buries the actual problem. Agents waste tokens parsing noise instead of fixing bugs.
This extension solves that by producing two clean, stable output files after every test run:
ai-report.json— structured data ready for programmatic consumptionai-report.txt— compact human-and-agent-readable summary
Every failure record contains exactly what an agent needs:
| Field | What it gives the agent |
|---|---|
exception.message |
The plain-English failure reason |
exception.comparison_diff |
A unified diff when values don't match — no more guessing what changed |
trace |
Cleaned stack frames, vendor noise removed, capped to a useful depth |
scenario_steps |
The Codeception steps leading up to the failure |
hints |
Pre-computed triage suggestions (assertion mismatch, missing element, etc.) |
artifacts |
Paths to screenshots, HAR files, and other test artifacts |
With the --report flag, the same context is also printed inline in the terminal output immediately after each failure — useful for agents that read stdout directly.
Installation
composer require --dev WebProject-xyz/codeception-module-ai-reporter
Requires PHP ^8.3 and Codeception ^5.3.5.
Setup
Add the extension to your codeception.yml:
extensions: enabled: - WebProject\Codeception\Module\AiReporter\Extension\AiReporter: format: both # text | json | both output: tests/_output max_frames: 8 include_steps: true include_artifacts: true compact_paths: true
Usage
Standard run
vendor/bin/codecept run
Report files are written to tests/_output/ after every run, regardless of whether tests pass or fail.
Agent run mode (--report)
vendor/bin/codecept run --report
Enables inline AI context — a structured block printed directly below each failure in the terminal:
AI Context
Test failed: MyTest: check value
Exception: PHPUnit\Framework\ExpectationFailedException
Message: Failed asserting that two strings are identical.
Diff:
--- Expected
+++ Actual
@@ @@
-'expected-value'
+'actual-value'
Trace:
#1 tests/Unit/MyTest.php:42 MyTest->checkValue
Hints:
- Assertion mismatch detected; compare expected and actual values at the top non-vendor frame.
Recommended agent instruction
Drop this into your agent's system prompt or task description:
Run `vendor/bin/codecept run --report` and use the inline AI Context
plus tests/_output/ai-report.json to identify and fix failures.
Repeat until all tests pass.
Output format
JSON (ai-report.json)
A machine-readable schema is available at schema/ai-report.schema.json (JSON Schema 2020-12).
{
"run": {
"generated_at": "2026-02-19T12:00:00+00:00",
"duration_seconds": 1.23,
"project_root": "/repo/project",
"output_dir": "/repo/project/tests/_output"
},
"summary": {
"tests": 10, "successful": 9, "failures": 1,
"errors": 0, "warnings": 0, "assertions": 42,
"successful_run": false
},
"failures": [
{
"status": "failure",
"suite": "Unit",
"test": {
"display_name": "MyTest: check value",
"signature": "MyTest:checkValue",
"full_name": "MyTest:checkValue",
"file": "tests/Unit/MyTest.php"
},
"exception": {
"class": "PHPUnit\\Framework\\ExpectationFailedException",
"message": "Failed asserting that two strings are identical.",
"comparison_expected": "'expected-value'",
"comparison_actual": "'actual-value'",
"comparison_diff": "\n--- Expected\n+++ Actual\n@@ @@\n-'expected-value'\n+'actual-value'\n",
"previous": []
},
"scenario_steps": [],
"trace": [
{ "file": "tests/Unit/MyTest.php", "line": 42, "call": "MyTest->checkValue" }
],
"artifacts": {},
"hints": [
"Assertion mismatch detected; compare expected and actual values at the top non-vendor frame."
]
}
]
}
Text (ai-report.txt)
Context
generated_at: 2026-02-19T12:00:00+00:00
project_root: /repo/project
totals: tests=10 successful=9 failures=1 errors=0 warnings=0 skipped=0 incomplete=0 useless=0 assertions=42
Failure 1
status: failure
suite: Unit
test: MyTest: check value
test_file: tests/Unit/MyTest.php
test_signature: MyTest:checkValue
Exception
exception_class: PHPUnit\Framework\ExpectationFailedException
message: Failed asserting that two strings are identical.
comparison_expected: 'expected-value'
comparison_actual: 'actual-value'
comparison_diff:
--- Expected
+++ Actual
@@ @@
-'expected-value'
+'actual-value'
Scenario
none
Trace
#1 tests/Unit/MyTest.php:42 MyTest->checkValue
Hints
- Assertion mismatch detected; compare expected and actual values at the top non-vendor frame.
Configuration reference
| Option | Type | Default | Description |
|---|---|---|---|
format |
text|json|both |
both |
Which report files to write |
output |
string |
tests/_output |
Output directory for report files |
max_frames |
int |
8 |
Maximum stack frames per failure |
include_steps |
bool |
true |
Include Codeception scenario steps |
include_artifacts |
bool |
true |
Include test metadata artifacts (screenshots, etc.) |
compact_paths |
bool |
true |
Use project-relative paths where possible |
Platform support
- Linux, macOS, and Windows paths are all handled correctly.
- Paths are normalized to forward slashes in report output for consistency across platforms.
Contributing
Contributions are welcome. Please open an issue before submitting large changes.
composer test:build # rebuild Codeception actor classes composer test # run tests composer stan # PHPStan static analysis (level 7) composer cs:check # check code style composer cs:fix # auto-fix code style
License
MIT
webproject-xyz/codeception-module-ai-reporter 适用场景与选型建议
webproject-xyz/codeception-module-ai-reporter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.7k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 webproject-xyz/codeception-module-ai-reporter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webproject-xyz/codeception-module-ai-reporter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.7k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-19