evoloop-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evoloop_cli/__init__.py +3 -0
- evoloop_cli/__main__.py +10 -0
- evoloop_cli/_skills/evoloop-constitution/SKILL.md +59 -0
- evoloop_cli/_skills/evoloop-constitution/references/writing-guide.md +89 -0
- evoloop_cli/_skills/evoloop-constitution/templates/config.yaml +52 -0
- evoloop_cli/_skills/evoloop-constitution/templates/constitution.md +39 -0
- evoloop_cli/_skills/evoloop-evaluate/SKILL.md +85 -0
- evoloop_cli/_skills/evoloop-evaluate/schemas/parsed_report.schema.json +170 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_junit_report.py +311 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_pytest_report.py +276 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/parse_report.py +101 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/update_eval_index.py +111 -0
- evoloop_cli/_skills/evoloop-evaluate/scripts/validate_parsed_report.py +178 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/analysis.md +51 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/progress.md +42 -0
- evoloop_cli/_skills/evoloop-evaluate/templates/tasks.md +34 -0
- evoloop_cli/_skills/evoloop-evolve/SKILL.md +76 -0
- evoloop_cli/_skills/evoloop-evolve/scripts/evolve_state.py +333 -0
- evoloop_cli/_skills/evoloop-implement/SKILL.md +57 -0
- evoloop_cli/_skills/evoloop-implement/scripts/check_scope.py +154 -0
- evoloop_cli/_skills/evoloop-implement/scripts/commit_section.py +78 -0
- evoloop_cli/_skills/evoloop-init/SKILL.md +95 -0
- evoloop_cli/_skills/evoloop-init/scripts/scaffold_evals.py +546 -0
- evoloop_cli/_skills/evoloop-init/templates/common/evals/datasets/domain_flows.yaml +33 -0
- evoloop_cli/_skills/evoloop-init/templates/common/evaluations/README.md +9 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgentAdapter.java +13 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +71 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/DeterministicEvaluators.java +174 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +45 -0
- evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/FlowRunResult.java +25 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/__init__.py +1 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/adapter.py +63 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/deepagents_adapter.py +223 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/__init__.py +1 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/deterministic.py +234 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/llm_judge.py +189 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/fakes.py +26 -0
- evoloop_cli/_skills/evoloop-init/templates/python/evals/harness.py +100 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/conftest.py +38 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/test_agentic_flows.py +36 -0
- evoloop_cli/_skills/evoloop-init/templates/python/tests/test_eval_framework.py +175 -0
- evoloop_cli/_skills/evoloop-new/SKILL.md +125 -0
- evoloop_cli/_skills/evoloop-new/scripts/scaffold_agent.py +911 -0
- evoloop_cli/_skills/evoloop-new/templates/common/.evoloop/constitution.md +34 -0
- evoloop_cli/_skills/evoloop-new/templates/common/.gitignore +22 -0
- evoloop_cli/_skills/evoloop-new/templates/common/AGENTS.md +17 -0
- evoloop_cli/_skills/evoloop-new/templates/common/README.md +83 -0
- evoloop_cli/_skills/evoloop-new/templates/common/skills/__DOMAIN__/SKILL.md +21 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +113 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +85 -0
- evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/Fake__DOMAIN_PASCAL__Client.java +37 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/OpenAiCompatibleRunner.java +433 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +125 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +163 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +18 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/Application.java +15 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +167 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +41 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Factory.java +32 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +20 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/resources/application.yml +17 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/Application.java +17 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +159 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Config.java +32 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +40 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +25 -0
- evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/resources/application.yml +19 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_custom.gradle +33 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_langchain4j.gradle +40 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_micronaut.gradle +52 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_spring-ai.gradle +45 -0
- evoloop_cli/_skills/evoloop-new/templates/java/gradle/settings.gradle +1 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_custom.xml +57 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_langchain4j.xml +87 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_micronaut.xml +101 -0
- evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_spring-ai.xml +61 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/ConversationMemory.java +36 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/Default__DOMAIN_PASCAL__Client.java +9 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/DomainRecord.java +10 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/TurnOutcome.java +15 -0
- evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Client.java +8 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/fakes.py +22 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_custom.py +186 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_deepagents.py +100 -0
- evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/tests/test_eval_framework.py +196 -0
- evoloop_cli/_skills/evoloop-new/templates/python/pyproject.toml +18 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__init__.py +13 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__main__.py +6 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_custom.py +209 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_deepagents.py +61 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/cli.py +71 -0
- evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/client.py +31 -0
- evoloop_cli/_skills/evoloop-scenarios/SKILL.md +49 -0
- evoloop_cli/_skills/evoloop-scenarios/scripts/validate_scenarios.py +261 -0
- evoloop_cli/_skills/evoloop-scenarios/templates/scenario_schema.md +49 -0
- evoloop_cli/cli.py +331 -0
- evoloop_cli-0.1.0.dist-info/METADATA +214 -0
- evoloop_cli-0.1.0.dist-info/RECORD +103 -0
- evoloop_cli-0.1.0.dist-info/WHEEL +4 -0
- evoloop_cli-0.1.0.dist-info/entry_points.txt +2 -0
- evoloop_cli-0.1.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = ["pyyaml>=6.0"]
|
|
5
|
+
# ///
|
|
6
|
+
"""Deterministically parse JUnit XML reports (Java Maven Surefire / Gradle) into parsed.json (v1.0)."""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import re
|
|
13
|
+
import sys
|
|
14
|
+
import xml.etree.ElementTree as ET
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import yaml
|
|
19
|
+
|
|
20
|
+
DETERMINISTIC_EVALUATORS = [
|
|
21
|
+
"trajectory_match",
|
|
22
|
+
"tool_policy",
|
|
23
|
+
"efficiency_budget",
|
|
24
|
+
"groundedness",
|
|
25
|
+
]
|
|
26
|
+
JUDGE_EVALUATORS = [
|
|
27
|
+
"trajectory_quality",
|
|
28
|
+
"response_quality",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
CASE_ID_IN_BRACKETS_RE = re.compile(r"\[([^\]]+)\]")
|
|
32
|
+
CASE_ID_IN_FLOW_RE = re.compile(r"Flow\s+'([^']+)'\s+failed")
|
|
33
|
+
CHECK_FAILURE_RE = re.compile(r"^\s*-\s+\[([a-zA-Z0-9_]+)\]\s+(.+)$")
|
|
34
|
+
FINAL_RESP_RE = re.compile(r"^\s*Final response:\s*(.+)$")
|
|
35
|
+
TOOL_CALLS_RE = re.compile(r"^\s*Domain tool calls:\s*(.+)$")
|
|
36
|
+
SKILL_LOADED_RE = re.compile(r"^\s*Skill loaded \([^)]+\):\s*(true|false|True|False)$")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def format_duration(seconds: float | None) -> str:
|
|
40
|
+
if seconds is None:
|
|
41
|
+
return "—"
|
|
42
|
+
total = int(round(seconds))
|
|
43
|
+
mins, secs = divmod(total, 60)
|
|
44
|
+
if mins > 0:
|
|
45
|
+
return f"{mins}m {secs:02d}s"
|
|
46
|
+
return f"{secs}s"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _load_case_order(dataset_path: Path | None) -> list[dict[str, str]]:
|
|
50
|
+
if dataset_path is None or not dataset_path.is_file():
|
|
51
|
+
return []
|
|
52
|
+
data = yaml.safe_load(dataset_path.read_text(encoding="utf-8")) or {}
|
|
53
|
+
return [
|
|
54
|
+
{"id": c["id"], "category": str(c.get("category", "general"))}
|
|
55
|
+
for c in data.get("cases", [])
|
|
56
|
+
if isinstance(c, dict) and "id" in c
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _extract_case_id(testcase_name: str, failure_text: str) -> str:
|
|
61
|
+
m_flow = CASE_ID_IN_FLOW_RE.search(failure_text)
|
|
62
|
+
if m_flow:
|
|
63
|
+
return m_flow.group(1)
|
|
64
|
+
# JUnit 5 parameterized display names often look like "testAgenticFlow(Map)[1] case_id" or "testAgenticFlow[case_id]"
|
|
65
|
+
m_br = CASE_ID_IN_BRACKETS_RE.search(testcase_name)
|
|
66
|
+
if m_br:
|
|
67
|
+
inner = m_br.group(1).strip()
|
|
68
|
+
if not inner.isdigit():
|
|
69
|
+
return inner
|
|
70
|
+
# Check trailing text after "[1] "
|
|
71
|
+
after = testcase_name[m_br.end():].strip(" :-")
|
|
72
|
+
if after:
|
|
73
|
+
return after
|
|
74
|
+
return testcase_name.strip()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _parse_failure_text(text: str) -> dict[str, Any]:
|
|
78
|
+
failed_checks: list[dict[str, str]] = []
|
|
79
|
+
final_response = None
|
|
80
|
+
domain_tool_calls = None
|
|
81
|
+
skill_loaded = None
|
|
82
|
+
|
|
83
|
+
for line in text.splitlines():
|
|
84
|
+
m_check = CHECK_FAILURE_RE.match(line)
|
|
85
|
+
if m_check:
|
|
86
|
+
failed_checks.append(
|
|
87
|
+
{"evaluator": m_check.group(1), "reason": m_check.group(2).strip()}
|
|
88
|
+
)
|
|
89
|
+
continue
|
|
90
|
+
m_resp = FINAL_RESP_RE.match(line)
|
|
91
|
+
if m_resp:
|
|
92
|
+
final_response = m_resp.group(1).strip()
|
|
93
|
+
continue
|
|
94
|
+
m_tc = TOOL_CALLS_RE.match(line)
|
|
95
|
+
if m_tc:
|
|
96
|
+
domain_tool_calls = m_tc.group(1).strip()
|
|
97
|
+
continue
|
|
98
|
+
m_sk = SKILL_LOADED_RE.match(line)
|
|
99
|
+
if m_sk:
|
|
100
|
+
skill_loaded = m_sk.group(1).lower() == "true"
|
|
101
|
+
|
|
102
|
+
if not failed_checks:
|
|
103
|
+
first_line = next((ln.strip() for ln in text.splitlines() if ln.strip()), "Test failed.")
|
|
104
|
+
failed_checks.append({"evaluator": "runtime_error", "reason": first_line})
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
"failed_evaluators": [c["evaluator"] for c in failed_checks],
|
|
108
|
+
"failures": failed_checks,
|
|
109
|
+
"final_response": final_response,
|
|
110
|
+
"domain_tool_calls": domain_tool_calls,
|
|
111
|
+
"skill_loaded": skill_loaded,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _collect_xml_files(report_path: Path) -> list[Path]:
|
|
116
|
+
if report_path.is_dir():
|
|
117
|
+
files = sorted(report_path.glob("TEST-*.xml"))
|
|
118
|
+
return files if files else sorted(report_path.glob("*.xml"))
|
|
119
|
+
return [report_path]
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def parse_junit_xml_strings(
|
|
123
|
+
xml_docs: list[str],
|
|
124
|
+
*,
|
|
125
|
+
dataset_path: Path | None = None,
|
|
126
|
+
with_judge: bool | None = None,
|
|
127
|
+
stack: str = "java",
|
|
128
|
+
) -> dict[str, Any]:
|
|
129
|
+
"""Parse one or more JUnit XML report documents into parsed.json v1.0."""
|
|
130
|
+
total_duration = 0.0
|
|
131
|
+
has_duration = False
|
|
132
|
+
observed_cases: list[str] = []
|
|
133
|
+
failed_details: dict[str, dict[str, Any]] = {}
|
|
134
|
+
|
|
135
|
+
for doc in xml_docs:
|
|
136
|
+
root = ET.fromstring(doc)
|
|
137
|
+
suites = [root] if root.tag == "testsuite" else list(root.findall(".//testsuite"))
|
|
138
|
+
for suite in suites:
|
|
139
|
+
if suite.attrib.get("time") is not None:
|
|
140
|
+
try:
|
|
141
|
+
total_duration += float(suite.attrib["time"])
|
|
142
|
+
has_duration = True
|
|
143
|
+
except ValueError:
|
|
144
|
+
pass
|
|
145
|
+
for tc in suite.findall("testcase"):
|
|
146
|
+
if tc.find("skipped") is not None:
|
|
147
|
+
continue
|
|
148
|
+
tc_name = tc.attrib.get("name", "")
|
|
149
|
+
fail_el = tc.find("failure")
|
|
150
|
+
err_el = tc.find("error")
|
|
151
|
+
issue_el = fail_el if fail_el is not None else err_el
|
|
152
|
+
|
|
153
|
+
if issue_el is not None:
|
|
154
|
+
combined = "\n".join(
|
|
155
|
+
part
|
|
156
|
+
for part in [issue_el.attrib.get("message", ""), issue_el.text or ""]
|
|
157
|
+
if part
|
|
158
|
+
)
|
|
159
|
+
cid = _extract_case_id(tc_name, combined)
|
|
160
|
+
observed_cases.append(cid)
|
|
161
|
+
failed_details[cid] = _parse_failure_text(combined)
|
|
162
|
+
else:
|
|
163
|
+
cid = _extract_case_id(tc_name, "")
|
|
164
|
+
observed_cases.append(cid)
|
|
165
|
+
|
|
166
|
+
observed_evals = {
|
|
167
|
+
ev for d in failed_details.values() for ev in d["failed_evaluators"]
|
|
168
|
+
}
|
|
169
|
+
judge_active = bool(observed_evals & set(JUDGE_EVALUATORS)) if with_judge is None else with_judge
|
|
170
|
+
active_evaluators = list(DETERMINISTIC_EVALUATORS) + (
|
|
171
|
+
list(JUDGE_EVALUATORS) if judge_active else []
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
dataset_cases = _load_case_order(dataset_path)
|
|
175
|
+
dataset_cats = {c["id"]: c["category"] for c in dataset_cases}
|
|
176
|
+
|
|
177
|
+
if dataset_cases and (not observed_cases or len(observed_cases) == len(dataset_cases)):
|
|
178
|
+
case_entries = dataset_cases
|
|
179
|
+
else:
|
|
180
|
+
case_entries = [
|
|
181
|
+
{"id": cid, "category": dataset_cats.get(cid, "unknown")}
|
|
182
|
+
for cid in observed_cases
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
scenarios_total = len(observed_cases) if observed_cases else len(case_entries)
|
|
186
|
+
scenarios_failed = len(failed_details)
|
|
187
|
+
scenarios_passed = max(scenarios_total - scenarios_failed, 0)
|
|
188
|
+
|
|
189
|
+
checks_per_scenario = len(active_evaluators)
|
|
190
|
+
checks_total = scenarios_total * checks_per_scenario
|
|
191
|
+
total_failed_checks = sum(
|
|
192
|
+
min(len(d["failed_evaluators"]), checks_per_scenario)
|
|
193
|
+
for d in failed_details.values()
|
|
194
|
+
)
|
|
195
|
+
checks_passed = max(checks_total - total_failed_checks, 0)
|
|
196
|
+
|
|
197
|
+
evaluator_stats: dict[str, dict[str, Any]] = {}
|
|
198
|
+
for ev in active_evaluators:
|
|
199
|
+
failed_for_ev = [
|
|
200
|
+
cid for cid, d in failed_details.items() if ev in d["failed_evaluators"]
|
|
201
|
+
]
|
|
202
|
+
ev_passed = max(scenarios_total - len(failed_for_ev), 0)
|
|
203
|
+
evaluator_stats[ev] = {
|
|
204
|
+
"type": "deterministic" if ev in DETERMINISTIC_EVALUATORS else "llm_judge",
|
|
205
|
+
"passed": ev_passed,
|
|
206
|
+
"total": scenarios_total,
|
|
207
|
+
"pass_rate_pct": round((ev_passed / scenarios_total) * 100, 1) if scenarios_total else 0.0,
|
|
208
|
+
"failed_cases": failed_for_ev,
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
cases_summary: list[dict[str, Any]] = []
|
|
212
|
+
judge_only_failures: list[str] = []
|
|
213
|
+
for entry in case_entries:
|
|
214
|
+
cid = entry["id"]
|
|
215
|
+
if cid in failed_details:
|
|
216
|
+
d = failed_details[cid]
|
|
217
|
+
fevs = d["failed_evaluators"]
|
|
218
|
+
det_failed = [e for e in fevs if e in DETERMINISTIC_EVALUATORS]
|
|
219
|
+
judge_failed = [e for e in fevs if e in JUDGE_EVALUATORS]
|
|
220
|
+
if not det_failed and judge_failed:
|
|
221
|
+
judge_only_failures.append(cid)
|
|
222
|
+
cases_summary.append(
|
|
223
|
+
{
|
|
224
|
+
"id": cid,
|
|
225
|
+
"category": entry["category"],
|
|
226
|
+
"status": "FAIL",
|
|
227
|
+
"checks_passed": max(checks_per_scenario - len(fevs), 0),
|
|
228
|
+
"checks_total": checks_per_scenario,
|
|
229
|
+
**d,
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
else:
|
|
233
|
+
cases_summary.append(
|
|
234
|
+
{
|
|
235
|
+
"id": cid,
|
|
236
|
+
"category": entry["category"],
|
|
237
|
+
"status": "PASS",
|
|
238
|
+
"checks_passed": checks_per_scenario,
|
|
239
|
+
"checks_total": checks_per_scenario,
|
|
240
|
+
"failed_evaluators": [],
|
|
241
|
+
"failures": [],
|
|
242
|
+
"final_response": None,
|
|
243
|
+
"domain_tool_calls": None,
|
|
244
|
+
"skill_loaded": None,
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
det_total = scenarios_total * len(DETERMINISTIC_EVALUATORS)
|
|
249
|
+
det_failed_count = sum(
|
|
250
|
+
len([e for e in d["failed_evaluators"] if e in DETERMINISTIC_EVALUATORS])
|
|
251
|
+
for d in failed_details.values()
|
|
252
|
+
)
|
|
253
|
+
det_passed = max(det_total - det_failed_count, 0)
|
|
254
|
+
duration_seconds = round(total_duration, 3) if has_duration else None
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
"schema_version": "1.0",
|
|
258
|
+
"stack": stack,
|
|
259
|
+
"report_format": "junit-xml",
|
|
260
|
+
"scenarios_passed": scenarios_passed,
|
|
261
|
+
"scenarios_total": scenarios_total,
|
|
262
|
+
"scenario_pass_rate_pct": round((scenarios_passed / scenarios_total) * 100, 1) if scenarios_total else 0.0,
|
|
263
|
+
"checks_passed": checks_passed,
|
|
264
|
+
"checks_total": checks_total,
|
|
265
|
+
"check_pass_rate_pct": round((checks_passed / checks_total) * 100, 1) if checks_total else 0.0,
|
|
266
|
+
"deterministic_checks_passed": det_passed,
|
|
267
|
+
"deterministic_checks_total": det_total,
|
|
268
|
+
"judge_active": judge_active,
|
|
269
|
+
"duration_seconds": duration_seconds,
|
|
270
|
+
"duration_human": format_duration(duration_seconds),
|
|
271
|
+
"evaluators": evaluator_stats,
|
|
272
|
+
"judge_only_failures": judge_only_failures,
|
|
273
|
+
"cases": cases_summary,
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def main(argv: list[str] | None = None) -> int:
|
|
278
|
+
parser = argparse.ArgumentParser(description="Parse JUnit XML report(s) to parsed.json (v1.0).")
|
|
279
|
+
parser.add_argument("report", type=Path, help="Path to a JUnit XML file or directory of XML files.")
|
|
280
|
+
parser.add_argument("--dataset", type=Path, default=None, help="Optional YAML dataset path.")
|
|
281
|
+
parser.add_argument("--stack", default="java", help="Stack label to record (default: java).")
|
|
282
|
+
parser.add_argument("--with-judge", action="store_true", default=None)
|
|
283
|
+
parser.add_argument("--no-judge", action="store_false", dest="with_judge")
|
|
284
|
+
parser.add_argument("--out", type=Path, default=None, help="Optional file path to write JSON output.")
|
|
285
|
+
args = parser.parse_args(argv)
|
|
286
|
+
|
|
287
|
+
if not args.report.exists():
|
|
288
|
+
print(f"ERROR: Report path not found: {args.report}", file=sys.stderr)
|
|
289
|
+
return 2
|
|
290
|
+
|
|
291
|
+
xml_files = _collect_xml_files(args.report)
|
|
292
|
+
if not xml_files:
|
|
293
|
+
print(f"ERROR: No JUnit XML files found in {args.report}", file=sys.stderr)
|
|
294
|
+
return 2
|
|
295
|
+
|
|
296
|
+
parsed = parse_junit_xml_strings(
|
|
297
|
+
[f.read_text(encoding="utf-8") for f in xml_files],
|
|
298
|
+
dataset_path=args.dataset,
|
|
299
|
+
with_judge=args.with_judge,
|
|
300
|
+
stack=args.stack,
|
|
301
|
+
)
|
|
302
|
+
rendered = json.dumps(parsed, indent=2, ensure_ascii=False)
|
|
303
|
+
if args.out is not None:
|
|
304
|
+
args.out.write_text(rendered + "\n", encoding="utf-8")
|
|
305
|
+
else:
|
|
306
|
+
print(rendered)
|
|
307
|
+
return 0
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
if __name__ == "__main__":
|
|
311
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = ["pyyaml>=6.0"]
|
|
5
|
+
# ///
|
|
6
|
+
"""Deterministically parse a raw pytest agentic-flow report into structured JSON metrics."""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import re
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
import yaml
|
|
18
|
+
|
|
19
|
+
DETERMINISTIC_EVALUATORS = [
|
|
20
|
+
"trajectory_match",
|
|
21
|
+
"tool_policy",
|
|
22
|
+
"efficiency_budget",
|
|
23
|
+
"groundedness",
|
|
24
|
+
]
|
|
25
|
+
JUDGE_EVALUATORS = [
|
|
26
|
+
"trajectory_quality",
|
|
27
|
+
"response_quality",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
COLLECTED_RE = re.compile(r"collected\s+(\d+)\s+items?")
|
|
31
|
+
DURATION_RE = re.compile(r"in\s+(\d+(?:\.\d+)?)s\s*(?:\([^)]+\))?\s*=+\s*$", re.MULTILINE)
|
|
32
|
+
FAILURE_HEADER_RE = re.compile(r"^_+\s+\S+\[([^\]]+)\]\s+_+$", re.MULTILINE)
|
|
33
|
+
SHORT_FAILED_RE = re.compile(r"^FAILED\s+\S+\[([^\]]+)\]", re.MULTILINE)
|
|
34
|
+
CHECK_FAILURE_RE = re.compile(r"^\s*E\s+-\s+\[([a-zA-Z0-9_]+)\]\s+(.+)$")
|
|
35
|
+
FINAL_RESP_RE = re.compile(r"^\s*E\s+Final response:\s*(.+)$")
|
|
36
|
+
TOOL_CALLS_RE = re.compile(r"^\s*E\s+Domain tool calls:\s*(.+)$")
|
|
37
|
+
SKILL_LOADED_RE = re.compile(r"^\s*E\s+Skill loaded \([^)]+\):\s*(True|False)$")
|
|
38
|
+
SUMMARY_COUNTS_RE = re.compile(r"(?:(\d+)\s+failed)?(?:,\s*)?(?:(\d+)\s+passed)?")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def format_duration(seconds: float | None) -> str:
|
|
42
|
+
if seconds is None:
|
|
43
|
+
return "—"
|
|
44
|
+
total = int(round(seconds))
|
|
45
|
+
mins, secs = divmod(total, 60)
|
|
46
|
+
if mins > 0:
|
|
47
|
+
return f"{mins}m {secs:02d}s"
|
|
48
|
+
return f"{secs}s"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _load_case_order(dataset_path: Path | None) -> list[dict[str, str]]:
|
|
52
|
+
if dataset_path is None or not dataset_path.is_file():
|
|
53
|
+
return []
|
|
54
|
+
data = yaml.safe_load(dataset_path.read_text(encoding="utf-8")) or {}
|
|
55
|
+
return [
|
|
56
|
+
{"id": c["id"], "category": str(c.get("category", "general"))}
|
|
57
|
+
for c in data.get("cases", [])
|
|
58
|
+
if isinstance(c, dict) and "id" in c
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def parse_report(
|
|
63
|
+
report_text: str,
|
|
64
|
+
*,
|
|
65
|
+
dataset_path: Path | None = None,
|
|
66
|
+
with_judge: bool | None = None,
|
|
67
|
+
stack: str = "python",
|
|
68
|
+
) -> dict[str, Any]:
|
|
69
|
+
"""Parse raw pytest output from tests/test_agentic_flows.py into structured metrics."""
|
|
70
|
+
text = report_text.replace("\r\n", "\n").replace("\r", "\n")
|
|
71
|
+
|
|
72
|
+
collected_match = COLLECTED_RE.search(text)
|
|
73
|
+
collected = int(collected_match.group(1)) if collected_match else None
|
|
74
|
+
|
|
75
|
+
duration_match = DURATION_RE.search(text)
|
|
76
|
+
duration_seconds = float(duration_match.group(1)) if duration_match else None
|
|
77
|
+
|
|
78
|
+
# Parse detailed failure blocks
|
|
79
|
+
headers = list(FAILURE_HEADER_RE.finditer(text))
|
|
80
|
+
failed_details: dict[str, dict[str, Any]] = {}
|
|
81
|
+
for i, match in enumerate(headers):
|
|
82
|
+
case_id = match.group(1)
|
|
83
|
+
start = match.end()
|
|
84
|
+
end = headers[i + 1].start() if i + 1 < len(headers) else len(text)
|
|
85
|
+
block = text[start:end]
|
|
86
|
+
# Stop before warnings or short test summary if this is the last failure block
|
|
87
|
+
for sentinel in ("=== warnings summary ===", "=== short test summary info ==="):
|
|
88
|
+
s_idx = block.find(sentinel)
|
|
89
|
+
if s_idx != -1:
|
|
90
|
+
block = block[:s_idx]
|
|
91
|
+
|
|
92
|
+
failed_checks: list[dict[str, str]] = []
|
|
93
|
+
final_response = None
|
|
94
|
+
domain_tool_calls = None
|
|
95
|
+
skill_loaded = None
|
|
96
|
+
|
|
97
|
+
for line in block.splitlines():
|
|
98
|
+
m_check = CHECK_FAILURE_RE.match(line)
|
|
99
|
+
if m_check:
|
|
100
|
+
failed_checks.append(
|
|
101
|
+
{"evaluator": m_check.group(1), "reason": m_check.group(2).strip()}
|
|
102
|
+
)
|
|
103
|
+
continue
|
|
104
|
+
m_resp = FINAL_RESP_RE.match(line)
|
|
105
|
+
if m_resp:
|
|
106
|
+
final_response = m_resp.group(1).strip()
|
|
107
|
+
continue
|
|
108
|
+
m_tc = TOOL_CALLS_RE.match(line)
|
|
109
|
+
if m_tc:
|
|
110
|
+
domain_tool_calls = m_tc.group(1).strip()
|
|
111
|
+
continue
|
|
112
|
+
m_sk = SKILL_LOADED_RE.match(line)
|
|
113
|
+
if m_sk:
|
|
114
|
+
skill_loaded = m_sk.group(1) == "True"
|
|
115
|
+
|
|
116
|
+
failed_details[case_id] = {
|
|
117
|
+
"failed_evaluators": [c["evaluator"] for c in failed_checks],
|
|
118
|
+
"failures": failed_checks,
|
|
119
|
+
"final_response": final_response,
|
|
120
|
+
"domain_tool_calls": domain_tool_calls,
|
|
121
|
+
"skill_loaded": skill_loaded,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Also capture any FAILED ids from short summary (e.g. non-assertion runtime errors)
|
|
125
|
+
for m in SHORT_FAILED_RE.finditer(text):
|
|
126
|
+
cid = m.group(1)
|
|
127
|
+
if cid not in failed_details:
|
|
128
|
+
failed_details[cid] = {
|
|
129
|
+
"failed_evaluators": ["runtime_error"],
|
|
130
|
+
"failures": [{"evaluator": "runtime_error", "reason": "Test errored without evaluator assertion."}],
|
|
131
|
+
"final_response": None,
|
|
132
|
+
"domain_tool_calls": None,
|
|
133
|
+
"skill_loaded": None,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Determine whether judge evaluators were active
|
|
137
|
+
observed_evals = {
|
|
138
|
+
ev for d in failed_details.values() for ev in d["failed_evaluators"]
|
|
139
|
+
}
|
|
140
|
+
if with_judge is None:
|
|
141
|
+
judge_active = bool(observed_evals & set(JUDGE_EVALUATORS)) or "--run-judge" in text
|
|
142
|
+
else:
|
|
143
|
+
judge_active = with_judge
|
|
144
|
+
|
|
145
|
+
active_evaluators = list(DETERMINISTIC_EVALUATORS) + (
|
|
146
|
+
list(JUDGE_EVALUATORS) if judge_active else []
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
dataset_cases = _load_case_order(dataset_path)
|
|
150
|
+
if dataset_cases and (collected is None or collected == len(dataset_cases)):
|
|
151
|
+
case_entries = dataset_cases
|
|
152
|
+
else:
|
|
153
|
+
# Fallback if dataset not provided or targeted -k subset was run
|
|
154
|
+
case_entries = [{"id": cid, "category": "unknown"} for cid in failed_details]
|
|
155
|
+
|
|
156
|
+
scenarios_total = collected if collected is not None else len(case_entries)
|
|
157
|
+
scenarios_failed = len(failed_details)
|
|
158
|
+
scenarios_passed = max(scenarios_total - scenarios_failed, 0)
|
|
159
|
+
|
|
160
|
+
checks_per_scenario = len(active_evaluators)
|
|
161
|
+
checks_total = scenarios_total * checks_per_scenario
|
|
162
|
+
total_failed_checks = sum(
|
|
163
|
+
min(len(d["failed_evaluators"]), checks_per_scenario)
|
|
164
|
+
for d in failed_details.values()
|
|
165
|
+
)
|
|
166
|
+
checks_passed = max(checks_total - total_failed_checks, 0)
|
|
167
|
+
|
|
168
|
+
# Per-evaluator pass rates
|
|
169
|
+
evaluator_stats: dict[str, dict[str, Any]] = {}
|
|
170
|
+
for ev in active_evaluators:
|
|
171
|
+
failed_for_ev = [
|
|
172
|
+
cid for cid, d in failed_details.items() if ev in d["failed_evaluators"]
|
|
173
|
+
]
|
|
174
|
+
ev_passed = max(scenarios_total - len(failed_for_ev), 0)
|
|
175
|
+
evaluator_stats[ev] = {
|
|
176
|
+
"type": "deterministic" if ev in DETERMINISTIC_EVALUATORS else "llm_judge",
|
|
177
|
+
"passed": ev_passed,
|
|
178
|
+
"total": scenarios_total,
|
|
179
|
+
"pass_rate_pct": round((ev_passed / scenarios_total) * 100, 1) if scenarios_total else 0.0,
|
|
180
|
+
"failed_cases": failed_for_ev,
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# Per-case summary
|
|
184
|
+
cases_summary: list[dict[str, Any]] = []
|
|
185
|
+
judge_only_failures: list[str] = []
|
|
186
|
+
for entry in case_entries:
|
|
187
|
+
cid = entry["id"]
|
|
188
|
+
if cid in failed_details:
|
|
189
|
+
d = failed_details[cid]
|
|
190
|
+
fevs = d["failed_evaluators"]
|
|
191
|
+
det_failed = [e for e in fevs if e in DETERMINISTIC_EVALUATORS]
|
|
192
|
+
judge_failed = [e for e in fevs if e in JUDGE_EVALUATORS]
|
|
193
|
+
if not det_failed and judge_failed:
|
|
194
|
+
judge_only_failures.append(cid)
|
|
195
|
+
cases_summary.append(
|
|
196
|
+
{
|
|
197
|
+
"id": cid,
|
|
198
|
+
"category": entry["category"],
|
|
199
|
+
"status": "FAIL",
|
|
200
|
+
"checks_passed": max(checks_per_scenario - len(fevs), 0),
|
|
201
|
+
"checks_total": checks_per_scenario,
|
|
202
|
+
**d,
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
else:
|
|
206
|
+
cases_summary.append(
|
|
207
|
+
{
|
|
208
|
+
"id": cid,
|
|
209
|
+
"category": entry["category"],
|
|
210
|
+
"status": "PASS",
|
|
211
|
+
"checks_passed": checks_per_scenario,
|
|
212
|
+
"checks_total": checks_per_scenario,
|
|
213
|
+
"failed_evaluators": [],
|
|
214
|
+
"failures": [],
|
|
215
|
+
"final_response": None,
|
|
216
|
+
"domain_tool_calls": None,
|
|
217
|
+
"skill_loaded": None,
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
det_total = scenarios_total * len(DETERMINISTIC_EVALUATORS)
|
|
222
|
+
det_failed_count = sum(
|
|
223
|
+
len([e for e in d["failed_evaluators"] if e in DETERMINISTIC_EVALUATORS])
|
|
224
|
+
for d in failed_details.values()
|
|
225
|
+
)
|
|
226
|
+
det_passed = max(det_total - det_failed_count, 0)
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
"schema_version": "1.0",
|
|
230
|
+
"stack": stack,
|
|
231
|
+
"report_format": "pytest",
|
|
232
|
+
"scenarios_passed": scenarios_passed,
|
|
233
|
+
"scenarios_total": scenarios_total,
|
|
234
|
+
"scenario_pass_rate_pct": round((scenarios_passed / scenarios_total) * 100, 1) if scenarios_total else 0.0,
|
|
235
|
+
"checks_passed": checks_passed,
|
|
236
|
+
"checks_total": checks_total,
|
|
237
|
+
"check_pass_rate_pct": round((checks_passed / checks_total) * 100, 1) if checks_total else 0.0,
|
|
238
|
+
"deterministic_checks_passed": det_passed,
|
|
239
|
+
"deterministic_checks_total": det_total,
|
|
240
|
+
"judge_active": judge_active,
|
|
241
|
+
"duration_seconds": duration_seconds,
|
|
242
|
+
"duration_human": format_duration(duration_seconds),
|
|
243
|
+
"evaluators": evaluator_stats,
|
|
244
|
+
"judge_only_failures": judge_only_failures,
|
|
245
|
+
"cases": cases_summary,
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def main(argv: list[str] | None = None) -> int:
|
|
250
|
+
parser = argparse.ArgumentParser(description="Parse raw pytest agentic-flow report to JSON.")
|
|
251
|
+
parser.add_argument("report", type=Path, help="Path to raw pytest report file.")
|
|
252
|
+
parser.add_argument("--dataset", type=Path, default=None, help="Optional YAML dataset path for full case list.")
|
|
253
|
+
parser.add_argument("--with-judge", action="store_true", default=None, help="Force judge_active=True.")
|
|
254
|
+
parser.add_argument("--no-judge", action="store_false", dest="with_judge", help="Force judge_active=False.")
|
|
255
|
+
parser.add_argument("--out", type=Path, default=None, help="Optional file path to write JSON output.")
|
|
256
|
+
args = parser.parse_args(argv)
|
|
257
|
+
|
|
258
|
+
if not args.report.is_file():
|
|
259
|
+
print(f"ERROR: Report file not found: {args.report}", file=sys.stderr)
|
|
260
|
+
return 2
|
|
261
|
+
|
|
262
|
+
parsed = parse_report(
|
|
263
|
+
args.report.read_text(encoding="utf-8"),
|
|
264
|
+
dataset_path=args.dataset,
|
|
265
|
+
with_judge=args.with_judge,
|
|
266
|
+
)
|
|
267
|
+
rendered = json.dumps(parsed, indent=2, ensure_ascii=False)
|
|
268
|
+
if args.out is not None:
|
|
269
|
+
args.out.write_text(rendered + "\n", encoding="utf-8")
|
|
270
|
+
else:
|
|
271
|
+
print(rendered)
|
|
272
|
+
return 0
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
if __name__ == "__main__":
|
|
276
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env -S uv run --script
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.11"
|
|
4
|
+
# dependencies = ["pyyaml>=6.0"]
|
|
5
|
+
# ///
|
|
6
|
+
"""Stack-aware report parser dispatcher: formats raw test output into schema-validated parsed.json (v1.0)."""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
import yaml
|
|
16
|
+
|
|
17
|
+
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
18
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
19
|
+
|
|
20
|
+
from parse_junit_report import _collect_xml_files, parse_junit_xml_strings # noqa: E402
|
|
21
|
+
from parse_pytest_report import parse_report as parse_pytest_text # noqa: E402
|
|
22
|
+
from validate_parsed_report import validate_parsed_report # noqa: E402
|
|
23
|
+
|
|
24
|
+
STACK_DEFAULT_FORMAT = {
|
|
25
|
+
"python": "pytest",
|
|
26
|
+
"java": "junit-xml",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def resolve_stack_and_format(
|
|
31
|
+
config_path: Path | None,
|
|
32
|
+
stack_arg: str | None,
|
|
33
|
+
format_arg: str | None,
|
|
34
|
+
) -> tuple[str, str]:
|
|
35
|
+
cfg = yaml.safe_load(config_path.read_text(encoding="utf-8")) if (config_path and config_path.is_file()) else {}
|
|
36
|
+
proj = cfg.get("project") or {}
|
|
37
|
+
stack = stack_arg or proj.get("stack") or "python"
|
|
38
|
+
fmt = format_arg or proj.get("report_format") or STACK_DEFAULT_FORMAT.get(stack, "json")
|
|
39
|
+
return str(stack), str(fmt)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def main(argv: list[str] | None = None) -> int:
|
|
43
|
+
parser = argparse.ArgumentParser(
|
|
44
|
+
description="Parse a native test report into schema-validated parsed.json (v1.0)."
|
|
45
|
+
)
|
|
46
|
+
parser.add_argument("report", type=Path, help="Raw report file (pytest stdout, JUnit XML file/dir, or native parsed.json).")
|
|
47
|
+
parser.add_argument("--config", type=Path, default=Path(".evoloop/config.yaml"))
|
|
48
|
+
parser.add_argument("--dataset", type=Path, default=None, help="Optional YAML dataset path.")
|
|
49
|
+
parser.add_argument("--stack", default=None, help="Override project.stack from config.yaml.")
|
|
50
|
+
parser.add_argument("--format", dest="report_format", choices=["pytest", "junit-xml", "json"], default=None)
|
|
51
|
+
parser.add_argument("--with-judge", action="store_true", default=None)
|
|
52
|
+
parser.add_argument("--no-judge", action="store_false", dest="with_judge")
|
|
53
|
+
parser.add_argument("--out", type=Path, default=None, help="Write validated parsed.json to this path.")
|
|
54
|
+
args = parser.parse_args(argv)
|
|
55
|
+
|
|
56
|
+
if not args.report.exists():
|
|
57
|
+
print(f"ERROR: Report path not found: {args.report}", file=sys.stderr)
|
|
58
|
+
return 2
|
|
59
|
+
|
|
60
|
+
stack, fmt = resolve_stack_and_format(args.config, args.stack, args.report_format)
|
|
61
|
+
|
|
62
|
+
if fmt == "pytest":
|
|
63
|
+
parsed = parse_pytest_text(
|
|
64
|
+
args.report.read_text(encoding="utf-8"),
|
|
65
|
+
dataset_path=args.dataset,
|
|
66
|
+
with_judge=args.with_judge,
|
|
67
|
+
stack=stack,
|
|
68
|
+
)
|
|
69
|
+
elif fmt == "junit-xml":
|
|
70
|
+
xml_files = _collect_xml_files(args.report)
|
|
71
|
+
if not xml_files:
|
|
72
|
+
print(f"ERROR: No JUnit XML files found in {args.report}", file=sys.stderr)
|
|
73
|
+
return 2
|
|
74
|
+
parsed = parse_junit_xml_strings(
|
|
75
|
+
[f.read_text(encoding="utf-8") for f in xml_files],
|
|
76
|
+
dataset_path=args.dataset,
|
|
77
|
+
with_judge=args.with_judge,
|
|
78
|
+
stack=stack,
|
|
79
|
+
)
|
|
80
|
+
elif fmt == "json":
|
|
81
|
+
parsed = json.loads(args.report.read_text(encoding="utf-8"))
|
|
82
|
+
else:
|
|
83
|
+
print(f"ERROR: Unsupported report format: {fmt}", file=sys.stderr)
|
|
84
|
+
return 2
|
|
85
|
+
|
|
86
|
+
errors = validate_parsed_report(parsed)
|
|
87
|
+
if errors:
|
|
88
|
+
for e in errors:
|
|
89
|
+
print(f"SCHEMA ERROR: {e}", file=sys.stderr)
|
|
90
|
+
return 1
|
|
91
|
+
|
|
92
|
+
rendered = json.dumps(parsed, indent=2, ensure_ascii=False)
|
|
93
|
+
if args.out is not None:
|
|
94
|
+
args.out.write_text(rendered + "\n", encoding="utf-8")
|
|
95
|
+
else:
|
|
96
|
+
print(rendered)
|
|
97
|
+
return 0
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
raise SystemExit(main())
|