tancat 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.
- cli/__init__.py +21 -0
- cli/evidence_cli.py +376 -0
- cli/main.py +8 -0
- src/__init__.py +1 -0
- src/accessibility_enricher.py +411 -0
- src/agents/__init__.py +75 -0
- src/agents/director.py +106 -0
- src/agents/generator.py +135 -0
- src/agents/graph.py +117 -0
- src/agents/ingestion.py +340 -0
- src/agents/pipeline_graph.py +525 -0
- src/agents/pipeline_state.py +170 -0
- src/agents/planner.py +104 -0
- src/agents/prompt_safety.py +33 -0
- src/agents/state.py +40 -0
- src/agents/synthesizer.py +181 -0
- src/agents/validator.py +75 -0
- src/analyzer.py +284 -0
- src/aria_parser.py +330 -0
- src/artifact_validation.py +500 -0
- src/assertion_alignment.py +184 -0
- src/browser_utils.py +533 -0
- src/cart_seeding_scraper.py +161 -0
- src/ci_ignore.py +140 -0
- src/citation_surfaces.py +212 -0
- src/citation_verifier.py +277 -0
- src/cli/__init__.py +21 -0
- src/cli/color.py +62 -0
- src/cli/config.py +25 -0
- src/cli/evidence_generator.py +538 -0
- src/cli/headless.py +577 -0
- src/cli/input_parser.py +586 -0
- src/cli/main.py +920 -0
- src/cli/menu_renderer.py +883 -0
- src/cli/pipeline_runner.py +1463 -0
- src/cli/report_generator.py +450 -0
- src/cli/retro_ui.py +380 -0
- src/cli/run_results_display.py +212 -0
- src/cli/session.py +202 -0
- src/cli/terminal_adapter.py +145 -0
- src/cli/test_case_orchestrator.py +516 -0
- src/cli/testing_terminal.py +36 -0
- src/code_normalizer.py +410 -0
- src/code_postprocessor.py +1991 -0
- src/code_validator.py +174 -0
- src/config.py +126 -0
- src/content_scoping.py +176 -0
- src/coverage_utils.py +248 -0
- src/credential_redaction.py +242 -0
- src/data/ocr/PP-OCRv6_det_small.pth +0 -0
- src/data/ocr/PP-OCRv6_rec_small.pth +0 -0
- src/data/ocr/README.md +42 -0
- src/data/ocr/ch_ppocr_mobile_v2.0_cls_mobile.pth +0 -0
- src/data/ocr/manifest.json +37 -0
- src/data/ocr/ppocrv6_dict.txt +18708 -0
- src/element_enricher.py +337 -0
- src/element_matcher.py +1768 -0
- src/evidence_export.py +409 -0
- src/evidence_image.py +152 -0
- src/evidence_index.py +530 -0
- src/evidence_loader.py +258 -0
- src/evidence_report.py +1174 -0
- src/evidence_serializer.py +84 -0
- src/evidence_tracker.py +2711 -0
- src/export_service.py +344 -0
- src/failure_classifier.py +225 -0
- src/failure_reporter.py +486 -0
- src/file_utils.py +107 -0
- src/flow_memory.py +658 -0
- src/form_detector.py +134 -0
- src/form_login_utils.py +104 -0
- src/gantt_utils.py +194 -0
- src/heatmap_alignment.py +415 -0
- src/heatmap_utils.py +838 -0
- src/hover_click_utils.py +208 -0
- src/intent_matcher.py +849 -0
- src/journey_auth_detector.py +69 -0
- src/journey_enrichment.py +198 -0
- src/journey_executor.py +446 -0
- src/journey_models.py +197 -0
- src/journey_scraper.py +1476 -0
- src/journey_subprocess.py +83 -0
- src/learning_impact.py +581 -0
- src/learning_metrics.py +396 -0
- src/licensing/__init__.py +58 -0
- src/licensing/activation.py +532 -0
- src/licensing/entitlement.py +188 -0
- src/licensing/license.py +119 -0
- src/licensing/merchant.py +27 -0
- src/licensing/pricing.py +51 -0
- src/licensing/tiers.py +194 -0
- src/licensing/window.py +63 -0
- src/link_scoping.py +221 -0
- src/llm_cache.py +265 -0
- src/llm_client.py +559 -0
- src/llm_errors.py +29 -0
- src/llm_health.py +433 -0
- src/llm_providers/__init__.py +795 -0
- src/llm_reasoning_filter.py +173 -0
- src/locator_builder.py +307 -0
- src/locator_fallback.py +206 -0
- src/locator_repair.py +875 -0
- src/locator_scorer.py +321 -0
- src/navigation_target.py +173 -0
- src/ocr_backends.py +921 -0
- src/orchestrator.py +1334 -0
- src/page_identity.py +303 -0
- src/page_object_builder.py +621 -0
- src/pdf_ingest.py +718 -0
- src/pipeline_artifact_manager.py +386 -0
- src/pipeline_models.py +263 -0
- src/pipeline_report_service.py +125 -0
- src/pipeline_run_service.py +244 -0
- src/pipeline_writer.py +320 -0
- src/placeholder_orchestrator.py +3225 -0
- src/placeholder_resolver.py +935 -0
- src/placeholder_scorers.py +1681 -0
- src/pom_helpers.py +254 -0
- src/prerequisite_injector.py +514 -0
- src/project.py +73 -0
- src/prompt_builder.py +383 -0
- src/prompt_utils.py +267 -0
- src/provider_config.py +179 -0
- src/pytest_output_parser.py +354 -0
- src/rag_bundled.py +671 -0
- src/rag_learn.py +770 -0
- src/rag_retriever.py +234 -0
- src/rag_store.py +996 -0
- src/rag_store_lock.py +256 -0
- src/rag_switches.py +147 -0
- src/report_builder.py +243 -0
- src/report_formats.py +52 -0
- src/report_formatters.py +729 -0
- src/report_utils.py +28 -0
- src/role_mapper.py +215 -0
- src/run_history_chart.py +494 -0
- src/run_history_cli.py +257 -0
- src/run_result_persistence.py +405 -0
- src/run_utils.py +79 -0
- src/scraper.py +1031 -0
- src/section_scoper.py +305 -0
- src/secure_config.py +260 -0
- src/self_healing.py +934 -0
- src/semantic_candidate_ranker.py +442 -0
- src/semantic_matcher.py +239 -0
- src/settings_store.py +165 -0
- src/skeleton_parser.py +459 -0
- src/skeleton_validator.py +109 -0
- src/skip_manager.py +226 -0
- src/source_refs.py +178 -0
- src/spec_analyzer.py +543 -0
- src/sqlite_persistence.py +615 -0
- src/stateful_scraper.py +280 -0
- src/storage.py +204 -0
- src/test_generator.py +142 -0
- src/test_plan.py +217 -0
- src/test_structure_assembler.py +152 -0
- src/test_table.py +491 -0
- src/ui/__init__.py +1 -0
- src/ui/shared.py +81 -0
- src/ui/ui_downloads.py +51 -0
- src/ui/ui_evidence.py +716 -0
- src/ui/ui_journey.py +339 -0
- src/ui/ui_requirements.py +32 -0
- src/ui/ui_results.py +188 -0
- src/ui/ui_run_comparison.py +117 -0
- src/ui/ui_run_results.py +1375 -0
- src/ui/ui_saved_packages.py +411 -0
- src/ui/ui_sidebar.py +485 -0
- src/ui_pipeline.py +515 -0
- src/url_guard.py +350 -0
- src/url_inference.py +49 -0
- src/url_resolver.py +307 -0
- src/url_utils.py +91 -0
- src/usage_meter.py +360 -0
- src/user_story_parser.py +311 -0
- src/verification_strength.py +228 -0
- src/verify_baseline.py +276 -0
- src/version_check.py +370 -0
- src/version_info.py +49 -0
- src/vision_enricher.py +307 -0
- tancat-0.1.0.dist-info/METADATA +260 -0
- tancat-0.1.0.dist-info/RECORD +186 -0
- tancat-0.1.0.dist-info/WHEEL +4 -0
- tancat-0.1.0.dist-info/entry_points.txt +2 -0
- tancat-0.1.0.dist-info/licenses/LICENSE +108 -0
cli/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""CLI module for Playwright test generator.
|
|
2
|
+
|
|
3
|
+
IMPORTANT: This file is imported FIRST when `python -m cli.main` runs.
|
|
4
|
+
It forces UTF-8 output on Windows Git Bash (MINGW64)
|
|
5
|
+
where the default stdout encoding is cp1252, which cannot encode box-drawing
|
|
6
|
+
characters (┌, ─, ┐, etc.) used in the retro UI.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import io
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
# Force UTF-8 encoding BEFORE any other CLI module is imported.
|
|
13
|
+
# This must happen before retro_ui or menu_renderer are loaded.
|
|
14
|
+
if sys.stdout.encoding and sys.stdout.encoding.upper() not in ("UTF-8", "UTF8", "CP65001"):
|
|
15
|
+
# Re-wire stdout/stderr to UTF-8 writers. This works in Git Bash on Windows
|
|
16
|
+
# where the console may default to cp1252.
|
|
17
|
+
try:
|
|
18
|
+
sys.stdout = io.TextIOWrapper(open(sys.stdout.fileno(), "wb"), encoding="utf-8", write_through=True)
|
|
19
|
+
sys.stderr = io.TextIOWrapper(open(sys.stderr.fileno(), "wb"), encoding="utf-8", write_through=True)
|
|
20
|
+
except OSError, io.UnsupportedOperation:
|
|
21
|
+
pass # stdout already a TTY or pipe — can't re-wrap
|
cli/evidence_cli.py
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"""CLI for evidence search, inspection, rerun, and export (AI-028).
|
|
2
|
+
|
|
3
|
+
Usage::
|
|
4
|
+
|
|
5
|
+
# Search with timestamps
|
|
6
|
+
python -m cli.evidence_cli search --query "cart" --status failed --verbose
|
|
7
|
+
|
|
8
|
+
# Inspect a specific result
|
|
9
|
+
python -m cli.evidence_cli search --query "cart" --status failed
|
|
10
|
+
python -m cli.evidence_cli detail 3 # drill into result #3 from last search
|
|
11
|
+
|
|
12
|
+
# Rerun matching tests
|
|
13
|
+
python -m cli.evidence_cli search --query "cart" --status failed --rerun
|
|
14
|
+
|
|
15
|
+
# Export
|
|
16
|
+
python -m cli.evidence_cli export --format csv --status failed -o evidence.csv
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import subprocess
|
|
24
|
+
import sys
|
|
25
|
+
from datetime import datetime
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
from src.evidence_export import export_csv, export_junit_xml, export_ndjson
|
|
29
|
+
from src.evidence_index import EvidenceIndex
|
|
30
|
+
|
|
31
|
+
# ---------------------------------------------------------------------------
|
|
32
|
+
# Shared helpers
|
|
33
|
+
# ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _build_index() -> EvidenceIndex:
|
|
37
|
+
"""Build or refresh the evidence index."""
|
|
38
|
+
index = EvidenceIndex()
|
|
39
|
+
count = index.build_or_refresh()
|
|
40
|
+
if count:
|
|
41
|
+
print(f"Indexed {count} new/updated sidecar(s).")
|
|
42
|
+
return index
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _filter_kwargs(args: argparse.Namespace) -> dict:
|
|
46
|
+
"""Extract filter kwargs from parsed args."""
|
|
47
|
+
return {
|
|
48
|
+
"query": getattr(args, "query", "") or "",
|
|
49
|
+
"status": getattr(args, "status", None),
|
|
50
|
+
"url_domain": getattr(args, "domain", None),
|
|
51
|
+
"condition_prefix": getattr(args, "condition_prefix", None),
|
|
52
|
+
"story_ref": getattr(args, "story_ref", None),
|
|
53
|
+
"step_type": getattr(args, "step_type", None),
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _format_timestamp(iso_str: str) -> str:
|
|
58
|
+
"""Convert ISO-8601 to a human-readable local timestamp."""
|
|
59
|
+
if not iso_str:
|
|
60
|
+
return "—"
|
|
61
|
+
try:
|
|
62
|
+
dt = datetime.fromisoformat(iso_str.replace("Z", "+00:00"))
|
|
63
|
+
local = dt.astimezone()
|
|
64
|
+
return local.strftime("%Y-%m-%d %H:%M")
|
|
65
|
+
except ValueError, TypeError:
|
|
66
|
+
return iso_str[:16] if len(iso_str) >= 16 else iso_str
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _print_search_table(
|
|
70
|
+
results: list,
|
|
71
|
+
verbose: bool = False,
|
|
72
|
+
) -> None:
|
|
73
|
+
"""Print search results as a numbered table."""
|
|
74
|
+
if verbose:
|
|
75
|
+
header = f"{'#':<4} {'St':<3} {'Condition':<12} {'Test Name':<50} {'Story':<8} {'Recorded':<17} URL"
|
|
76
|
+
else:
|
|
77
|
+
header = f"{'#':<4} {'St':<3} {'Condition':<12} {'Test Name':<55} {'Story':<8} URL"
|
|
78
|
+
print(header)
|
|
79
|
+
print("-" * len(header))
|
|
80
|
+
|
|
81
|
+
status_icon = {
|
|
82
|
+
"failed": "\u274c",
|
|
83
|
+
"passed": "\u2705",
|
|
84
|
+
"skipped": "\u23ed\ufe0f",
|
|
85
|
+
"error": "\u274c",
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
for i, r in enumerate(results, 1):
|
|
89
|
+
icon = status_icon.get(r.status, "?")
|
|
90
|
+
name = r.test_name.replace("[chromium]", "")
|
|
91
|
+
if not verbose:
|
|
92
|
+
max_name = 52
|
|
93
|
+
else:
|
|
94
|
+
max_name = 47
|
|
95
|
+
if len(name) > max_name:
|
|
96
|
+
name = name[: max_name - 3] + "..."
|
|
97
|
+
url = r.page_url or ""
|
|
98
|
+
max_url = 60 if not verbose else 50
|
|
99
|
+
if len(url) > max_url:
|
|
100
|
+
url = url[: max_url - 3] + "..."
|
|
101
|
+
|
|
102
|
+
ts = _format_timestamp(r.indexed_at)
|
|
103
|
+
|
|
104
|
+
if verbose:
|
|
105
|
+
print(f"{i:<4} {icon:<3} {r.condition_ref:<12} {name:<50} {r.story_ref:<8} {ts:<17} {url}")
|
|
106
|
+
else:
|
|
107
|
+
print(f"{i:<4} {icon:<3} {r.condition_ref:<12} {name:<55} {r.story_ref:<8} {url}")
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# ---------------------------------------------------------------------------
|
|
111
|
+
# search
|
|
112
|
+
# ---------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _cmd_search(args: argparse.Namespace) -> None:
|
|
116
|
+
"""Search evidence sidecars and print results as a table."""
|
|
117
|
+
index = _build_index()
|
|
118
|
+
results = index.search(**_filter_kwargs(args))
|
|
119
|
+
|
|
120
|
+
if not results:
|
|
121
|
+
print("No evidence matches your search.")
|
|
122
|
+
return
|
|
123
|
+
|
|
124
|
+
_print_search_table(results, verbose=args.verbose)
|
|
125
|
+
print(f"\n{len(results)} result(s).")
|
|
126
|
+
|
|
127
|
+
# Save results to a temp file so 'detail' can reference them
|
|
128
|
+
_save_last_results(results)
|
|
129
|
+
|
|
130
|
+
if args.rerun:
|
|
131
|
+
_rerun_tests(results)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _save_last_results(results: list) -> None:
|
|
135
|
+
"""Save search results to a temp file for cross-command reference."""
|
|
136
|
+
import tempfile
|
|
137
|
+
|
|
138
|
+
data = [
|
|
139
|
+
{
|
|
140
|
+
"sidecar_path": r.sidecar_path,
|
|
141
|
+
"test_name": r.test_name,
|
|
142
|
+
"test_package": r.test_package,
|
|
143
|
+
}
|
|
144
|
+
for r in results
|
|
145
|
+
]
|
|
146
|
+
path = Path(tempfile.gettempdir()) / "evidence_cli_last_results.json"
|
|
147
|
+
path.write_text(json.dumps(data))
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _load_last_results() -> list[dict]:
|
|
151
|
+
"""Load the last search results from the temp file."""
|
|
152
|
+
import tempfile
|
|
153
|
+
|
|
154
|
+
path = Path(tempfile.gettempdir()) / "evidence_cli_last_results.json"
|
|
155
|
+
if not path.exists():
|
|
156
|
+
return []
|
|
157
|
+
try:
|
|
158
|
+
return json.loads(path.read_text()) # type: ignore[no-any-return]
|
|
159
|
+
except json.JSONDecodeError, OSError:
|
|
160
|
+
return []
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def _rerun_tests(results: list) -> None:
|
|
164
|
+
"""Rerun pytest on the test packages that produced the search results."""
|
|
165
|
+
packages = sorted({r.test_package for r in results if r.test_package})
|
|
166
|
+
if not packages:
|
|
167
|
+
print("No test packages to rerun.")
|
|
168
|
+
return
|
|
169
|
+
|
|
170
|
+
from src.storage import get_storage
|
|
171
|
+
|
|
172
|
+
gen_dir = get_storage().generated_tests_dir()
|
|
173
|
+
test_files: list[str] = []
|
|
174
|
+
for pkg_name in packages:
|
|
175
|
+
pkg_dir = gen_dir / pkg_name
|
|
176
|
+
if pkg_dir.exists():
|
|
177
|
+
test_files.extend(str(f) for f in pkg_dir.glob("test_*.py") if f.name != "conftest.py")
|
|
178
|
+
|
|
179
|
+
if not test_files:
|
|
180
|
+
print(f"No test files found in packages: {', '.join(packages)}")
|
|
181
|
+
return
|
|
182
|
+
|
|
183
|
+
print(f"\nRerunning {len(test_files)} test file(s) from {len(packages)} package(s)...")
|
|
184
|
+
cmd = [sys.executable, "-m", "pytest", *test_files, "-v", "--tb=short"]
|
|
185
|
+
subprocess.run(cmd)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# ---------------------------------------------------------------------------
|
|
189
|
+
# detail
|
|
190
|
+
# ---------------------------------------------------------------------------
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _cmd_detail(args: argparse.Namespace) -> None:
|
|
194
|
+
"""Show detailed evidence for a result from the last search."""
|
|
195
|
+
last = _load_last_results()
|
|
196
|
+
if not last:
|
|
197
|
+
print("No previous search results. Run 'search' first.")
|
|
198
|
+
return
|
|
199
|
+
|
|
200
|
+
idx = args.number - 1
|
|
201
|
+
if idx < 0 or idx >= len(last):
|
|
202
|
+
print(f"Result #{args.number} not found. Last search had {len(last)} results.")
|
|
203
|
+
return
|
|
204
|
+
|
|
205
|
+
entry = last[idx]
|
|
206
|
+
index = _build_index()
|
|
207
|
+
sidecar = index.get_sidecar_detail(entry["sidecar_path"])
|
|
208
|
+
|
|
209
|
+
if sidecar is None:
|
|
210
|
+
print(f"Could not load sidecar: {entry['sidecar_path']}")
|
|
211
|
+
return
|
|
212
|
+
|
|
213
|
+
test = sidecar.get("test", {})
|
|
214
|
+
page = sidecar.get("page", {})
|
|
215
|
+
steps = sidecar.get("steps", [])
|
|
216
|
+
|
|
217
|
+
print(f"\n{'=' * 70}")
|
|
218
|
+
print(f" Test: {test.get('name', '?')}")
|
|
219
|
+
print(f" Condition: {test.get('condition_ref', '?')}")
|
|
220
|
+
print(f" Story: {test.get('story_ref', '?')}")
|
|
221
|
+
print(f" Status: {test.get('status', '?')}")
|
|
222
|
+
print(f" Page URL: {page.get('url', '?')}")
|
|
223
|
+
print(f" Package: {entry['test_package']}")
|
|
224
|
+
print(f"{'=' * 70}")
|
|
225
|
+
|
|
226
|
+
if steps:
|
|
227
|
+
print(f"\nSteps ({len(steps)}):")
|
|
228
|
+
for s in steps:
|
|
229
|
+
step_num = s.get("step", "?")
|
|
230
|
+
step_type = s.get("type", "?")
|
|
231
|
+
label = s.get("label", "")
|
|
232
|
+
result = s.get("result", {})
|
|
233
|
+
step_status = result.get("status", "?")
|
|
234
|
+
elapsed = result.get("elapsed_ms", 0)
|
|
235
|
+
error = result.get("error") or result.get("failure_note")
|
|
236
|
+
|
|
237
|
+
icon = "\u2705" if step_status == "passed" else "\u274c"
|
|
238
|
+
print(f" {icon} Step {step_num} [{step_type}]: {label}")
|
|
239
|
+
if elapsed:
|
|
240
|
+
print(f" ({elapsed}ms)")
|
|
241
|
+
if error:
|
|
242
|
+
print(f" \u26a0\ufe0f {error}")
|
|
243
|
+
else:
|
|
244
|
+
print("\n (no steps recorded)")
|
|
245
|
+
|
|
246
|
+
# Also show locator info if available
|
|
247
|
+
for s in steps:
|
|
248
|
+
locator = s.get("locator")
|
|
249
|
+
if locator:
|
|
250
|
+
print(f"\n Locator used: {locator}")
|
|
251
|
+
break
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
# ---------------------------------------------------------------------------
|
|
255
|
+
# export
|
|
256
|
+
# ---------------------------------------------------------------------------
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _cmd_export(args: argparse.Namespace) -> None:
|
|
260
|
+
"""Export evidence to CSV, NDJSON, or JUnit XML."""
|
|
261
|
+
fmt = args.format
|
|
262
|
+
output = Path(args.output).resolve()
|
|
263
|
+
index = _build_index()
|
|
264
|
+
kwargs = _filter_kwargs(args)
|
|
265
|
+
|
|
266
|
+
# Count matching results before export
|
|
267
|
+
results = index.search(**{**kwargs, "limit": 100_000})
|
|
268
|
+
result_count = len(results)
|
|
269
|
+
|
|
270
|
+
if result_count == 0:
|
|
271
|
+
print("No evidence matches your filters. Nothing exported.")
|
|
272
|
+
return
|
|
273
|
+
|
|
274
|
+
if fmt == "csv":
|
|
275
|
+
export_csv(index, output=output, **kwargs)
|
|
276
|
+
elif fmt == "ndjson":
|
|
277
|
+
export_ndjson(index, output=output, **kwargs)
|
|
278
|
+
elif fmt == "junit":
|
|
279
|
+
export_junit_xml(index, output=output, **kwargs)
|
|
280
|
+
else:
|
|
281
|
+
print(f"Unknown format: {fmt}", file=sys.stderr)
|
|
282
|
+
sys.exit(1)
|
|
283
|
+
|
|
284
|
+
size_kb = output.stat().st_size / 1024 if output.exists() else 0
|
|
285
|
+
|
|
286
|
+
# Build a human-readable filter summary
|
|
287
|
+
filters: list[str] = []
|
|
288
|
+
if kwargs.get("query"):
|
|
289
|
+
filters.append(f'query="{kwargs["query"]}"')
|
|
290
|
+
if kwargs.get("status"):
|
|
291
|
+
filters.append(f"status={kwargs['status']}")
|
|
292
|
+
if kwargs.get("url_domain"):
|
|
293
|
+
filters.append(f"domain={kwargs['url_domain']}")
|
|
294
|
+
if kwargs.get("condition_prefix"):
|
|
295
|
+
filters.append(f"prefix={kwargs['condition_prefix']}")
|
|
296
|
+
if kwargs.get("story_ref"):
|
|
297
|
+
filters.append(f"story={kwargs['story_ref']}")
|
|
298
|
+
filter_str = ", ".join(filters) if filters else "all evidence"
|
|
299
|
+
|
|
300
|
+
print(f"Exported {result_count} sidecar(s) [{filter_str}] to {output} ({size_kb:.1f} KB)")
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
# ---------------------------------------------------------------------------
|
|
304
|
+
# CLI entry point
|
|
305
|
+
# ---------------------------------------------------------------------------
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def main(argv: list[str] | None = None) -> None:
|
|
309
|
+
parser = argparse.ArgumentParser(
|
|
310
|
+
description="Search, inspect, rerun, and export Playwright test evidence.",
|
|
311
|
+
prog="evidence-cli",
|
|
312
|
+
)
|
|
313
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
314
|
+
|
|
315
|
+
# ── search ────────────────────────────────────────────────────────────
|
|
316
|
+
p_search = sub.add_parser("search", help="Search evidence sidecars")
|
|
317
|
+
p_search.add_argument("--query", "-q", default="", help="Free-text search query")
|
|
318
|
+
p_search.add_argument("--status", choices=["passed", "failed", "skipped", "error"])
|
|
319
|
+
p_search.add_argument("--domain", help="URL domain filter (e.g. automationexercise.com)")
|
|
320
|
+
p_search.add_argument("--condition-prefix", help="Condition ref prefix (e.g. TC01)")
|
|
321
|
+
p_search.add_argument("--story-ref", help="Story reference (e.g. S06)")
|
|
322
|
+
p_search.add_argument("--step-type", choices=["navigate", "click", "fill", "assertion", "select"])
|
|
323
|
+
p_search.add_argument(
|
|
324
|
+
"--verbose",
|
|
325
|
+
"-v",
|
|
326
|
+
action="store_true",
|
|
327
|
+
help="Show recorded timestamps and full details",
|
|
328
|
+
)
|
|
329
|
+
p_search.add_argument(
|
|
330
|
+
"--rerun",
|
|
331
|
+
action="store_true",
|
|
332
|
+
help="Rerun pytest on the test packages matching search results",
|
|
333
|
+
)
|
|
334
|
+
p_search.set_defaults(func=_cmd_search)
|
|
335
|
+
|
|
336
|
+
# ── detail ────────────────────────────────────────────────────────────
|
|
337
|
+
p_detail = sub.add_parser(
|
|
338
|
+
"detail",
|
|
339
|
+
help="Show step-by-step evidence for a result from the last search",
|
|
340
|
+
)
|
|
341
|
+
p_detail.add_argument(
|
|
342
|
+
"number",
|
|
343
|
+
type=int,
|
|
344
|
+
help="Result number from the last search (e.g. 3)",
|
|
345
|
+
)
|
|
346
|
+
p_detail.set_defaults(func=_cmd_detail)
|
|
347
|
+
|
|
348
|
+
# ── export ────────────────────────────────────────────────────────────
|
|
349
|
+
p_export = sub.add_parser("export", help="Export evidence to file")
|
|
350
|
+
p_export.add_argument(
|
|
351
|
+
"--format",
|
|
352
|
+
"-f",
|
|
353
|
+
required=True,
|
|
354
|
+
choices=["csv", "ndjson", "junit"],
|
|
355
|
+
help="Export format",
|
|
356
|
+
)
|
|
357
|
+
p_export.add_argument(
|
|
358
|
+
"--output",
|
|
359
|
+
"-o",
|
|
360
|
+
required=True,
|
|
361
|
+
help="Output file path",
|
|
362
|
+
)
|
|
363
|
+
p_export.add_argument("--query", "-q", default="", help="Free-text search query")
|
|
364
|
+
p_export.add_argument("--status", choices=["passed", "failed", "skipped", "error"])
|
|
365
|
+
p_export.add_argument("--domain", help="URL domain filter")
|
|
366
|
+
p_export.add_argument("--condition-prefix", help="Condition ref prefix")
|
|
367
|
+
p_export.add_argument("--story-ref", help="Story reference")
|
|
368
|
+
p_export.add_argument("--step-type", choices=["navigate", "click", "fill", "assertion", "select"])
|
|
369
|
+
p_export.set_defaults(func=_cmd_export)
|
|
370
|
+
|
|
371
|
+
args = parser.parse_args(argv)
|
|
372
|
+
args.func(args)
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
if __name__ == "__main__":
|
|
376
|
+
main()
|
cli/main.py
ADDED
src/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Source module for Playwright test generator."""
|