qa-engineer 0.9.2 → 0.11.0

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.
Files changed (147) hide show
  1. package/COMPATIBILITY.md +26 -12
  2. package/README.md +182 -84
  3. package/package.json +11 -20
  4. package/packages/engine/bin/qa-engine.mjs +560 -0
  5. package/packages/engine/lib/analysis/branding.mjs +187 -0
  6. package/packages/engine/lib/analysis/context.mjs +294 -0
  7. package/packages/engine/lib/analysis/contracts.mjs +149 -0
  8. package/packages/engine/lib/analysis/diff-guard.mjs +425 -0
  9. package/packages/engine/lib/analysis/discovery.mjs +220 -0
  10. package/packages/engine/lib/analysis/evidence.mjs +116 -0
  11. package/packages/engine/lib/analysis/har.mjs +124 -0
  12. package/packages/engine/lib/analysis/junit.mjs +126 -0
  13. package/packages/engine/lib/analysis/network.mjs +237 -0
  14. package/packages/engine/lib/analysis/redaction.mjs +127 -0
  15. package/packages/engine/lib/analysis/report-html.mjs +76 -0
  16. package/packages/engine/lib/analysis/taxonomy.mjs +109 -0
  17. package/packages/engine/lib/analysis/xml.mjs +153 -0
  18. package/packages/engine/lib/analysis/zip.mjs +107 -0
  19. package/packages/engine/lib/artifacts/manager.mjs +453 -0
  20. package/packages/engine/lib/artifacts/mime.mjs +109 -0
  21. package/packages/engine/lib/artifacts/zip-write.mjs +143 -0
  22. package/packages/engine/lib/diagnostics/engine.mjs +165 -0
  23. package/packages/engine/lib/diagnostics/internal-contracts.mjs +50 -0
  24. package/packages/engine/lib/diagnostics/prioritization.mjs +99 -0
  25. package/packages/engine/lib/diagnostics/repair.mjs +73 -0
  26. package/packages/engine/lib/diagnostics/root-cause.mjs +92 -0
  27. package/packages/engine/lib/diagnostics/timeline.mjs +101 -0
  28. package/packages/engine/lib/frameworks/junit-frameworks.mjs +48 -0
  29. package/packages/engine/lib/frameworks/playwright.mjs +158 -0
  30. package/packages/engine/lib/report/components/charts.mjs +424 -0
  31. package/packages/engine/lib/report/components/evidence.mjs +207 -0
  32. package/packages/engine/lib/report/components/findings.mjs +258 -0
  33. package/packages/engine/lib/report/components/nav.mjs +99 -0
  34. package/packages/engine/lib/report/components/primitives.mjs +246 -0
  35. package/packages/engine/lib/report/components/runtime.mjs +246 -0
  36. package/packages/engine/lib/report/components/timeline.mjs +65 -0
  37. package/packages/engine/lib/report/core/model.mjs +270 -0
  38. package/packages/engine/lib/report/core/normalize.mjs +226 -0
  39. package/packages/engine/lib/report/core/sections.mjs +978 -0
  40. package/packages/engine/lib/report/export/bundle.mjs +293 -0
  41. package/packages/engine/lib/report/export/html.mjs +183 -0
  42. package/packages/engine/lib/report/export/machine.mjs +290 -0
  43. package/packages/engine/lib/report/export/markdown.mjs +323 -0
  44. package/packages/engine/lib/report/schemas/qa-report.schema.json +555 -0
  45. package/packages/engine/lib/report/theme/css.mjs +529 -0
  46. package/packages/engine/lib/report/theme/tokens.mjs +137 -0
  47. package/packages/engine/lib/report/version.mjs +78 -0
  48. package/packages/engine/package.json +14 -0
  49. package/packages/installer/lib/agents/targets.mjs +90 -0
  50. package/packages/installer/lib/agents/user-level.mjs +80 -0
  51. package/packages/installer/lib/cli/flags.mjs +20 -2
  52. package/packages/installer/lib/commands/doctor.mjs +13 -20
  53. package/packages/installer/lib/commands/install.mjs +160 -91
  54. package/packages/installer/lib/commands/repair.mjs +10 -6
  55. package/packages/installer/lib/commands/self-test.mjs +4 -3
  56. package/packages/installer/lib/commands/uninstall.mjs +14 -8
  57. package/packages/installer/lib/commands/update.mjs +9 -4
  58. package/packages/installer/lib/commands/verify.mjs +13 -12
  59. package/packages/installer/lib/constants.mjs +13 -0
  60. package/packages/installer/lib/core/bundle.mjs +69 -92
  61. package/packages/installer/lib/core/conflict.mjs +5 -4
  62. package/packages/installer/lib/core/fs-safe.mjs +146 -6
  63. package/packages/installer/lib/core/integrity.mjs +59 -0
  64. package/packages/installer/lib/core/lockfile.mjs +19 -3
  65. package/packages/installer/lib/core/manifest.mjs +48 -57
  66. package/packages/installer/lib/core/plan.mjs +213 -0
  67. package/packages/installer/lib/core/qa-home.mjs +145 -0
  68. package/packages/installer/lib/core/scope.mjs +274 -0
  69. package/packages/installer/lib/core/validate-install.mjs +49 -31
  70. package/packages/installer/package.json +1 -1
  71. package/packages/installer/schemas/qa-lock.schema.json +119 -21
  72. package/shared/tooling/qa-tool.mjs +161 -0
  73. package/skills/qa-api/SKILL.md +5 -5
  74. package/skills/qa-api/references/deterministic-tooling.md +34 -32
  75. package/skills/qa-api/references/evidence-and-reporting.md +5 -5
  76. package/skills/qa-api/scripts/qa-tool.mjs +162 -0
  77. package/skills/qa-audit/SKILL.md +5 -5
  78. package/skills/qa-audit/references/deterministic-tooling.md +34 -32
  79. package/skills/qa-audit/references/evidence-and-reporting.md +5 -5
  80. package/skills/qa-audit/scripts/qa-tool.mjs +162 -0
  81. package/skills/qa-debug/SKILL.md +6 -6
  82. package/skills/qa-debug/references/deterministic-tooling.md +34 -32
  83. package/skills/qa-debug/references/diagnostic-engine.md +3 -3
  84. package/skills/qa-debug/references/evidence-and-reporting.md +5 -5
  85. package/skills/qa-debug/scripts/qa-tool.mjs +162 -0
  86. package/skills/qa-explore/SKILL.md +31 -15
  87. package/skills/qa-explore/contracts/explore-result.schema.json +517 -11
  88. package/skills/qa-explore/references/api-replay.md +40 -1
  89. package/skills/qa-explore/references/deterministic-tooling.md +34 -32
  90. package/skills/qa-explore/references/evidence-and-reporting.md +5 -5
  91. package/skills/qa-explore/references/report-pipeline.md +266 -96
  92. package/skills/qa-explore/scripts/qa-tool.mjs +162 -0
  93. package/skills/qa-fix/SKILL.md +4 -4
  94. package/skills/qa-fix/references/deterministic-tooling.md +34 -32
  95. package/skills/qa-fix/references/diagnostic-engine.md +3 -3
  96. package/skills/qa-fix/references/evidence-and-reporting.md +5 -5
  97. package/skills/qa-fix/scripts/qa-tool.mjs +162 -0
  98. package/skills/qa-flaky/SKILL.md +4 -4
  99. package/skills/qa-flaky/references/deterministic-tooling.md +34 -32
  100. package/skills/qa-flaky/references/evidence-and-reporting.md +5 -5
  101. package/skills/qa-flaky/scripts/qa-tool.mjs +162 -0
  102. package/skills/qa-generate/references/evidence-and-reporting.md +5 -5
  103. package/skills/qa-init/SKILL.md +4 -4
  104. package/skills/qa-init/references/deterministic-tooling.md +34 -32
  105. package/skills/qa-init/references/evidence-and-reporting.md +5 -5
  106. package/skills/qa-init/scripts/qa-tool.mjs +162 -0
  107. package/skills/qa-report/SKILL.md +7 -7
  108. package/skills/qa-report/references/deterministic-tooling.md +34 -32
  109. package/skills/qa-report/references/diagnostic-engine.md +3 -3
  110. package/skills/qa-report/references/evidence-and-reporting.md +5 -5
  111. package/skills/qa-report/scripts/qa-tool.mjs +162 -0
  112. package/skills/qa-review/references/evidence-and-reporting.md +5 -5
  113. package/skills/qa-run/SKILL.md +6 -6
  114. package/skills/qa-run/references/deterministic-tooling.md +34 -32
  115. package/skills/qa-run/references/evidence-and-reporting.md +5 -5
  116. package/skills/qa-run/scripts/qa-tool.mjs +162 -0
  117. package/shared/analysis/lib/qa_analysis/__init__.py +0 -11
  118. package/shared/analysis/lib/qa_analysis/branding.py +0 -175
  119. package/shared/analysis/lib/qa_analysis/cli.py +0 -144
  120. package/shared/analysis/lib/qa_analysis/context.py +0 -233
  121. package/shared/analysis/lib/qa_analysis/contracts.py +0 -158
  122. package/shared/analysis/lib/qa_analysis/diff_guard.py +0 -327
  123. package/shared/analysis/lib/qa_analysis/discovery.py +0 -113
  124. package/shared/analysis/lib/qa_analysis/evidence.py +0 -128
  125. package/shared/analysis/lib/qa_analysis/har.py +0 -87
  126. package/shared/analysis/lib/qa_analysis/junit.py +0 -104
  127. package/shared/analysis/lib/qa_analysis/redaction.py +0 -107
  128. package/shared/analysis/lib/qa_analysis/report_html.py +0 -781
  129. package/shared/analysis/lib/qa_analysis/taxonomy.py +0 -98
  130. package/shared/diagnostics/lib/qa_diagnostics/__init__.py +0 -13
  131. package/shared/diagnostics/lib/qa_diagnostics/cli.py +0 -124
  132. package/shared/diagnostics/lib/qa_diagnostics/engine.py +0 -143
  133. package/shared/diagnostics/lib/qa_diagnostics/internal_contracts.py +0 -75
  134. package/shared/diagnostics/lib/qa_diagnostics/prioritization.py +0 -101
  135. package/shared/diagnostics/lib/qa_diagnostics/repair.py +0 -72
  136. package/shared/diagnostics/lib/qa_diagnostics/root_cause.py +0 -89
  137. package/shared/diagnostics/lib/qa_diagnostics/timeline.py +0 -71
  138. package/shared/frameworks/cypress/lib/cypress_analysis.py +0 -27
  139. package/shared/frameworks/playwright/lib/playwright_analysis.py +0 -167
  140. package/shared/frameworks/selenium/lib/selenium_analysis.py +0 -28
  141. package/shared/frameworks/webdriverio/lib/webdriverio_analysis.py +0 -24
  142. package/shared/tooling/qa_tool.py +0 -127
  143. /package/{shared/analysis/lib/qa_analysis → packages/engine/lib/analysis}/branding.json +0 -0
  144. /package/{shared → packages/engine/lib}/analysis/schemas/context.schema.json +0 -0
  145. /package/{shared → packages/engine/lib}/diagnostics/schemas/internal/analysis-result.schema.json +0 -0
  146. /package/{shared → packages/engine/lib}/diagnostics/schemas/internal/diagnosis.schema.json +0 -0
  147. /package/{shared → packages/engine/lib}/diagnostics/schemas/internal/execution-result-min.schema.json +0 -0
@@ -1,89 +0,0 @@
1
- """Deterministic root-cause analysis.
2
-
3
- Turns a failure signal into a classified root cause with the four things every
4
- classification must carry: a taxonomy class (with confidence and evidence-backed
5
- reason), a recommended action, and an owner. It reuses the analysis platform's
6
- failure taxonomy; it adds the ownership and recommendation mappings and the
7
- metadata-driven classes (flaky) the taxonomy cannot infer from a message alone.
8
-
9
- No unsupported conclusions: a signal that matches no rule is `unknown`.
10
- """
11
-
12
- from qa_analysis import taxonomy
13
-
14
- # classification -> the party that typically owns the fix.
15
- OWNERSHIP = {
16
- taxonomy.ASSERTION: "test-author-or-product",
17
- taxonomy.LOCATOR: "test-author",
18
- taxonomy.TIMEOUT: "test-author-or-environment",
19
- taxonomy.NETWORK: "backend-or-infrastructure",
20
- taxonomy.AUTH: "auth-or-test-setup",
21
- taxonomy.AUTHORIZATION: "permissions-or-test-account",
22
- taxonomy.ENVIRONMENT: "environment-owner",
23
- taxonomy.CONFIGURATION: "config-owner",
24
- taxonomy.INFRASTRUCTURE: "ci-or-infrastructure",
25
- taxonomy.TEST_DATA: "test-data-owner",
26
- taxonomy.APPLICATION_BUG: "product",
27
- taxonomy.FRAMEWORK: "framework-or-driver",
28
- taxonomy.FLAKY: "test-author",
29
- taxonomy.UNKNOWN: "needs-triage",
30
- }
31
-
32
- # classification -> the safe recommended action (implements the analysis
33
- # platform's recommendation-guidelines; never recommends forcing a pass).
34
- RECOMMENDATION = {
35
- taxonomy.ASSERTION: "Confirm whether the app or the expectation is wrong; fix whichever is genuinely incorrect.",
36
- taxonomy.LOCATOR: "Inspect the current DOM and update the locator to target the same element.",
37
- taxonomy.TIMEOUT: "Investigate the slowness; raise a wait only if the operation is legitimately slower.",
38
- taxonomy.NETWORK: "Check the upstream service and the request; retry only if the failure is genuinely transient.",
39
- taxonomy.AUTH: "Fix the credentials or auth setup; do not weaken the authentication check.",
40
- taxonomy.AUTHORIZATION: "Grant the test account the needed permission or use an authorized role; do not bypass the check.",
41
- taxonomy.ENVIRONMENT: "Fix the environment (base URL, service availability); the test is likely fine.",
42
- taxonomy.CONFIGURATION: "Correct the configuration; do not work around it in the test.",
43
- taxonomy.INFRASTRUCTURE: "Escalate to CI or infrastructure owners; add resources, do not shrink the suite.",
44
- taxonomy.TEST_DATA: "Repair or reseed the data; do not delete the assertion that caught the gap.",
45
- taxonomy.APPLICATION_BUG: "File a bug against the product; do NOT modify the test to pass.",
46
- taxonomy.FRAMEWORK: "Update or pin the framework/driver; report upstream if it is a genuine defect.",
47
- taxonomy.FLAKY: "Stabilize the test (fix the race or synchronization); quarantine only with a tracking issue.",
48
- taxonomy.UNKNOWN: "Investigate further; the evidence was insufficient to classify.",
49
- }
50
-
51
-
52
- def analyze(signal):
53
- """Classify a failure signal into a root cause.
54
-
55
- signal is a dict that may contain: message, httpStatus, retries, finalStatus,
56
- evidence (a list of evidence refs). Returns a dict:
57
- {classification, confidence, reason, ownership, recommendation, evidence}.
58
- """
59
- message = signal.get("message", "")
60
- http_status = signal.get("httpStatus")
61
- retries = signal.get("retries", 0) or 0
62
- final_status = signal.get("finalStatus")
63
-
64
- provided = signal.get("classification")
65
-
66
- # Flakiness is a metadata signal, not a message pattern: a test that needed a
67
- # retry to pass, or is explicitly flagged flaky, is nondeterministic.
68
- if final_status == "flaky" or (retries > 0 and final_status in ("passed", "flaky")):
69
- classification, confidence, reason = (
70
- taxonomy.FLAKY, 0.8,
71
- "The test passed only after a retry, indicating nondeterministic behavior.",
72
- )
73
- elif provided in taxonomy.CLASSES:
74
- # The analysis platform already classified this deterministically; trust it
75
- # rather than re-deriving from the message.
76
- classification = provided
77
- confidence = signal.get("confidence", 0.8)
78
- reason = signal.get("reason") or f"Classified {provided} by the analysis platform."
79
- else:
80
- classification, confidence, reason = taxonomy.classify(message, http_status=http_status)
81
-
82
- return {
83
- "classification": classification,
84
- "confidence": confidence,
85
- "reason": reason,
86
- "ownership": OWNERSHIP.get(classification, "needs-triage"),
87
- "recommendation": RECOMMENDATION.get(classification, RECOMMENDATION[taxonomy.UNKNOWN]),
88
- "evidence": signal.get("evidence", []),
89
- }
@@ -1,71 +0,0 @@
1
- """Deterministic timeline reconstruction.
2
-
3
- Reconstructs the ordered sequence of a run — start, browser launch, navigation,
4
- requests and responses, console errors, assertions, failure, cleanup — from the
5
- execution result and the analysis findings. It records only stages for which
6
- there is evidence; it never invents an event to fill the shape. Reusable by
7
- qa-debug and qa-report.
8
- """
9
-
10
- # Canonical phase order, used to sort events that share (or lack) a timestamp.
11
- PHASE_ORDER = [
12
- "execution-start", "browser-launch", "navigation", "request", "response",
13
- "console-error", "assertion", "failure", "cleanup", "execution-finish",
14
- ]
15
- _PHASE_INDEX = {phase: i for i, phase in enumerate(PHASE_ORDER)}
16
-
17
- # Evidence type -> the timeline phase it contributes.
18
- _EVIDENCE_PHASE = {
19
- "network": "response",
20
- "console": "console-error",
21
- "trace": "navigation",
22
- "junit": "assertion",
23
- "report": "assertion",
24
- }
25
-
26
-
27
- def build_timeline(execution_result, findings=None):
28
- """Build an ordered timeline. Returns a list of event dicts:
29
- {order, phase, detail, source, timestamp?}. Deterministic: same inputs,
30
- same timeline. Only evidenced stages appear."""
31
- events = []
32
- execution = (execution_result or {}).get("execution", {})
33
-
34
- started = execution.get("startedAt")
35
- if started or execution_result:
36
- events.append(_event("execution-start", "Run started", "execution-result", started))
37
-
38
- # Contribute a stage per evidence entry we actually have.
39
- for finding in findings or []:
40
- for ev in finding.get("evidence", []):
41
- phase = _EVIDENCE_PHASE.get(ev.get("type"))
42
- if phase:
43
- events.append(_event(phase, ev.get("description", ""), ev.get("source", "analysis"), None))
44
-
45
- # A failure stage per failed test recorded in the result.
46
- for test in (execution_result or {}).get("executed", []):
47
- if test.get("status") == "failed":
48
- events.append(_event("failure", f"Test failed: {test.get('title', '')}",
49
- test.get("file", "execution-result"), None))
50
-
51
- finished = execution.get("finishedAt")
52
- if finished:
53
- events.append(_event("cleanup", "Run cleaned up", "execution-result", None))
54
- events.append(_event("execution-finish", "Run finished", "execution-result", finished))
55
-
56
- # Deterministic order: by canonical phase first (it encodes the logical
57
- # sequence), then by timestamp within a phase, then by insertion order. Phase
58
- # order is primary because per-event wall-clock times are often unavailable.
59
- for i, event in enumerate(events):
60
- event["_seq"] = i
61
- events.sort(key=lambda e: (_PHASE_INDEX.get(e["phase"], 99), e["timestamp"] or "", e["_seq"]))
62
- for order, event in enumerate(events):
63
- event["order"] = order
64
- del event["_seq"]
65
- if event["timestamp"] is None:
66
- del event["timestamp"]
67
- return events
68
-
69
-
70
- def _event(phase, detail, source, timestamp):
71
- return {"phase": phase, "detail": detail, "source": source, "timestamp": timestamp}
@@ -1,27 +0,0 @@
1
- """Cypress analysis adapter.
2
-
3
- Cypress emits JUnit XML (via a JUnit reporter), so Cypress normalization is the
4
- framework-agnostic JUnit parser — the adapter only points at the artifact and
5
- tags provenance. Like the Selenium adapter, its thinness is the proof of the
6
- multi-framework boundary: the contract and parsing are shared; only the artifact
7
- location differs.
8
- """
9
-
10
- from qa_analysis import junit, taxonomy
11
-
12
- FRAMEWORK = "cypress"
13
-
14
- # Where Cypress projects conventionally write JUnit results (see cypress-artifacts.md).
15
- RESULT_GLOBS = ["**/results/*.xml", "**/cypress/results/*.xml", "**/junit*.xml"]
16
-
17
-
18
- def normalize(junit_path):
19
- """Normalize a Cypress run into the shared result shape via the agnostic
20
- JUnit parser. Identical output shape to any other framework."""
21
- return junit.parse_junit(junit_path)
22
-
23
-
24
- def classify_failure(message, http_status=None):
25
- """Classify a Cypress failure using the shared taxonomy — no Cypress-specific
26
- classifier, because failure classes are framework-agnostic."""
27
- return taxonomy.classify(message, http_status=http_status)
@@ -1,167 +0,0 @@
1
- """Playwright-specific analyzers: trace and JSON report.
2
-
3
- These are the Playwright *adapter* for the analysis platform. They depend on
4
- the framework-agnostic qa_analysis core for the evidence model, redaction, and
5
- the failure taxonomy; they add only what is Playwright-specific — the shape of
6
- a Playwright trace.zip and of Playwright's JSON reporter. Everything they emit
7
- is in the shared normalized shape, so nothing downstream knows it was Playwright.
8
-
9
- The adapter carries its own CLI (`python -m playwright_analysis report|trace
10
- <path>`) so a skill can reach it the same way it reaches every other
11
- deterministic tool. Framework knowledge stays inside the adapter: the core CLI
12
- never grows a `--framework` flag ([ADR-0013](../../../../docs/architecture/ADR-0013-framework-boundary.md)).
13
-
14
- Usage:
15
- python -m playwright_analysis report <results.json>
16
- python -m playwright_analysis trace <trace.zip>
17
- """
18
-
19
- import argparse
20
- import json
21
- import sys
22
- import zipfile
23
-
24
- from qa_analysis.junit import MalformedArtifact
25
- from qa_analysis.redaction import redact_text
26
- from qa_analysis import taxonomy
27
-
28
-
29
- def parse_report(path):
30
- """Parse Playwright's JSON reporter output into the normalized result shape.
31
-
32
- Mirrors qa_analysis.junit's output ({tests, executed}) so a Playwright run
33
- normalizes identically whether it emitted JSON or JUnit. Raises
34
- MalformedArtifact on unreadable input.
35
- """
36
- try:
37
- with open(path, "r", encoding="utf-8") as handle:
38
- data = json.load(handle)
39
- except (json.JSONDecodeError, OSError, UnicodeDecodeError) as exc:
40
- raise MalformedArtifact(f"could not parse Playwright report at {path}: {exc}") from exc
41
-
42
- executed = []
43
- for suite in data.get("suites", []):
44
- _walk_suite(suite, executed)
45
-
46
- counts = {
47
- "total": len(executed),
48
- "passed": sum(1 for e in executed if e["status"] == "passed"),
49
- "failed": sum(1 for e in executed if e["status"] == "failed"),
50
- "skipped": sum(1 for e in executed if e["status"] == "skipped"),
51
- }
52
- return {"tests": counts, "executed": executed}
53
-
54
-
55
- def _walk_suite(suite, executed):
56
- for spec in suite.get("specs", []):
57
- for test in spec.get("tests", []):
58
- results = test.get("results", [])
59
- status = _status_of(results)
60
- message = ""
61
- if status == "failed" and results:
62
- errors = results[-1].get("errors") or []
63
- if errors:
64
- message = redact_text((errors[0].get("message") or "").strip())
65
- entry = {
66
- "title": spec.get("title", ""),
67
- "file": suite.get("file", ""),
68
- "status": status,
69
- "durationMs": results[-1].get("duration", 0) if results else 0,
70
- "retries": max(0, len(results) - 1),
71
- }
72
- if message:
73
- entry["message"] = message
74
- executed.append(entry)
75
- for child in suite.get("suites", []):
76
- _walk_suite(child, executed)
77
-
78
-
79
- def _status_of(results):
80
- if not results:
81
- return "skipped"
82
- final = results[-1].get("status")
83
- if final in ("passed", "expected"):
84
- return "flaky" if len(results) > 1 else "passed"
85
- if final in ("skipped",):
86
- return "skipped"
87
- return "failed"
88
-
89
-
90
- def analyze_trace(path):
91
- """Extract a deterministic summary from a Playwright trace.zip.
92
-
93
- A trace is a zip of newline-delimited JSON event files. This lists the
94
- actions, surfaces the last error, and counts console and network events —
95
- enough for a diagnostic skill to reason over, without decoding the full
96
- binary. Raises MalformedArtifact if the file is not a valid trace zip.
97
- """
98
- if not zipfile.is_zipfile(path):
99
- raise MalformedArtifact(f"not a valid trace zip: {path}")
100
-
101
- actions, console, network, errors = [], 0, 0, []
102
- try:
103
- with zipfile.ZipFile(path) as archive:
104
- names = [n for n in archive.namelist() if n.endswith(".trace") or n.endswith(".jsonl") or "trace" in n]
105
- for name in names or archive.namelist():
106
- with archive.open(name) as member:
107
- for raw in member.read().decode("utf-8", "replace").splitlines():
108
- raw = raw.strip()
109
- if not raw or not raw.startswith("{"):
110
- continue
111
- try:
112
- event = json.loads(raw)
113
- except json.JSONDecodeError:
114
- continue
115
- kind = event.get("type") or event.get("kind")
116
- if kind in ("action", "before"):
117
- actions.append(redact_text(str(event.get("apiName") or event.get("method") or "")))
118
- elif kind == "console":
119
- console += 1
120
- elif kind in ("resource", "network", "http"):
121
- network += 1
122
- if event.get("error") or kind == "error":
123
- msg = event.get("error", {}).get("message") if isinstance(event.get("error"), dict) else event.get("message")
124
- if msg:
125
- errors.append(redact_text(str(msg)))
126
- except (OSError, KeyError) as exc:
127
- raise MalformedArtifact(f"could not read trace {path}: {exc}") from exc
128
-
129
- last_error = errors[-1] if errors else ""
130
- classification, confidence, reason = taxonomy.classify(last_error) if last_error else (taxonomy.UNKNOWN, 0.2, "No error found in trace.")
131
- return {
132
- "actions": [a for a in actions if a],
133
- "consoleEvents": console,
134
- "networkEvents": network,
135
- "errors": errors,
136
- "classification": classification,
137
- "confidence": confidence,
138
- "reason": reason,
139
- }
140
-
141
-
142
- def main(argv=None):
143
- """CLI: JSON to stdout, exit 0 on success, 2 on a malformed artifact."""
144
- parser = argparse.ArgumentParser(
145
- prog="playwright_analysis",
146
- description="Playwright adapter: normalize a JSON report or summarize a trace",
147
- )
148
- sub = parser.add_subparsers(dest="command", required=True)
149
- p = sub.add_parser("report", help="normalize Playwright's JSON reporter output")
150
- p.add_argument("path")
151
- p = sub.add_parser("trace", help="summarize a Playwright trace.zip")
152
- p.add_argument("path")
153
- args = parser.parse_args(argv)
154
-
155
- try:
156
- result = parse_report(args.path) if args.command == "report" else analyze_trace(args.path)
157
- except MalformedArtifact as exc:
158
- json.dump({"error": "malformed-artifact", "detail": str(exc)}, sys.stdout, indent=2, sort_keys=True)
159
- sys.stdout.write("\n")
160
- return 2
161
- json.dump(result, sys.stdout, indent=2, sort_keys=True)
162
- sys.stdout.write("\n")
163
- return 0
164
-
165
-
166
- if __name__ == "__main__":
167
- sys.exit(main())
@@ -1,28 +0,0 @@
1
- """Selenium analysis adapter.
2
-
3
- Selenium's runners (JUnit, TestNG, pytest) emit JUnit XML, so Selenium
4
- normalization *is* the framework-agnostic JUnit parser — the adapter only points
5
- at the right artifact and tags provenance. This is the proof of the pack's
6
- multi-framework claim: the second framework's analysis is a few lines, because
7
- the contract and the parsing are shared, and only the artifact location differs.
8
- """
9
-
10
- from qa_analysis import junit, taxonomy
11
-
12
- FRAMEWORK = "selenium"
13
-
14
- # Where Selenium projects conventionally write results (documented in
15
- # selenium-artifacts.md); discovery uses these, the parser is shared.
16
- RESULT_GLOBS = ["**/target/surefire-reports/*.xml", "**/test-results/*.xml", "**/junit*.xml"]
17
-
18
-
19
- def normalize(junit_path):
20
- """Normalize a Selenium run into the shared result shape via the agnostic
21
- JUnit parser. Identical output shape to any other framework's normalization."""
22
- return junit.parse_junit(junit_path)
23
-
24
-
25
- def classify_failure(message, http_status=None):
26
- """Classify a Selenium failure using the shared taxonomy — no Selenium-specific
27
- classifier, because failure classes are framework-agnostic."""
28
- return taxonomy.classify(message, http_status=http_status)
@@ -1,24 +0,0 @@
1
- """WebdriverIO analysis adapter.
2
-
3
- WebdriverIO emits JUnit XML (via @wdio/junit-reporter), so its normalization is
4
- the framework-agnostic JUnit parser — the adapter points at the artifact and
5
- tags provenance. Thin by design: the fourth framework confirms the boundary.
6
- """
7
-
8
- from qa_analysis import junit, taxonomy
9
-
10
- FRAMEWORK = "webdriverio"
11
-
12
- # Where WebdriverIO projects conventionally write JUnit results.
13
- RESULT_GLOBS = ["**/junit*.xml", "**/results/*.xml", "**/test-results/*.xml"]
14
-
15
-
16
- def normalize(junit_path):
17
- """Normalize a WebdriverIO run into the shared result shape via the agnostic
18
- JUnit parser. Identical output shape to any other framework."""
19
- return junit.parse_junit(junit_path)
20
-
21
-
22
- def classify_failure(message, http_status=None):
23
- """Classify a WebdriverIO failure using the shared taxonomy."""
24
- return taxonomy.classify(message, http_status=http_status)
@@ -1,127 +0,0 @@
1
- #!/usr/bin/env python3
2
- """The single entry point for a skill's bundled deterministic tooling.
3
-
4
- Every skill that carries an engine also carries a copy of this file at
5
- `<skill>/scripts/qa_tool.py`, beside the `lib/` directory it dispatches into.
6
-
7
- ## Why this exists
8
-
9
- The invocation used to be a shell recipe:
10
-
11
- QA_LIB="$(ls -d .agents/skills/qa-run/scripts/lib ... | head -1)"
12
- PYTHONPATH="$QA_LIB" python3 -m qa_analysis.cli junit report.xml
13
-
14
- Three parts of that are POSIX-only — command substitution, `ls -d | head -1`, and
15
- the `VAR=value command` prefix — so on Windows PowerShell every deterministic call
16
- failed. Failing calls do not stop a skill; they push it onto its documented manual
17
- fallback. The result was that Windows users silently got the *guessing* behaviour
18
- this project exists to replace, while believing they had the tooling.
19
-
20
- So the shell does no work at all now. This launcher finds its own `lib/`
21
- directory from `__file__` and puts it on `sys.path` itself:
22
-
23
- python3 .agents/skills/qa-run/scripts/qa_tool.py analysis junit report.xml
24
-
25
- That line is identical in bash, zsh, PowerShell, and cmd.exe. On Windows, use
26
- `python` if `python3` is not on PATH — that is the only remaining difference.
27
-
28
- ## Usage
29
-
30
- qa_tool.py analysis <subcommand> [args] -> qa_analysis.cli
31
- qa_tool.py diagnostics <subcommand> [args] -> qa_diagnostics.cli
32
- qa_tool.py playwright <subcommand> [args] -> playwright_analysis
33
- qa_tool.py --list what this skill bundles
34
-
35
- Exit codes pass through from the underlying tool unchanged: 0 success, 1 an
36
- invalid contract, 2 unreadable input or a payload that failed its contract.
37
- """
38
-
39
- import os
40
- import pathlib
41
- import sys
42
-
43
- _HERE = pathlib.Path(__file__).resolve().parent
44
- _LIB = _HERE / "lib"
45
-
46
- # Tool name -> (module path, callable). Resolved lazily so a skill that bundles
47
- # only part of the toolkit still runs the parts it has.
48
- _TOOLS = {
49
- "analysis": ("qa_analysis.cli", "main"),
50
- "diagnostics": ("qa_diagnostics.cli", "main"),
51
- "playwright": ("playwright_analysis", "main"),
52
- }
53
-
54
- _USAGE = """usage: qa_tool.py <tool> <subcommand> [args]
55
-
56
- analysis parse artifacts, classify errors, validate contracts, diff-guard
57
- diagnostics root cause, timeline, priority, repair plans
58
- playwright normalize a Playwright report or summarize a trace
59
-
60
- --list show which tools this skill bundles
61
-
62
- examples:
63
- python3 qa_tool.py analysis junit test-results/results.xml
64
- python3 qa_tool.py analysis diff-guard change.diff
65
- python3 qa_tool.py diagnostics report --execution-result qa-artifacts/run.json
66
- python3 qa_tool.py playwright report test-results/results.json
67
- """
68
-
69
-
70
- def _available():
71
- """Tools whose module is importable from this skill's bundled lib/."""
72
- found = []
73
- for name, (module, _) in _TOOLS.items():
74
- top = module.split(".")[0]
75
- if (_LIB / top).is_dir() or (_LIB / f"{top}.py").is_file():
76
- found.append(name)
77
- return found
78
-
79
-
80
- def main(argv=None):
81
- argv = list(sys.argv[1:] if argv is None else argv)
82
-
83
- if not _LIB.is_dir():
84
- sys.stderr.write(
85
- f"qa_tool: no bundled library at {_LIB}\n"
86
- "The skill's deterministic engine is missing. Run: qa repair --project .\n"
87
- )
88
- return 2
89
-
90
- # The bundled lib is authoritative: prepend so a same-named package installed
91
- # elsewhere on the machine cannot shadow the version that shipped with this skill.
92
- sys.path.insert(0, str(_LIB))
93
-
94
- if not argv or argv[0] in ("-h", "--help", "help"):
95
- sys.stdout.write(_USAGE)
96
- return 0
97
-
98
- if argv[0] == "--list":
99
- available = _available()
100
- sys.stdout.write(
101
- "bundled tools: " + (", ".join(available) if available else "none") + "\n"
102
- )
103
- return 0 if available else 2
104
-
105
- tool = argv[0]
106
- if tool not in _TOOLS:
107
- sys.stderr.write(f"qa_tool: unknown tool {tool!r}\n\n{_USAGE}")
108
- return 2
109
-
110
- module_name, entry = _TOOLS[tool]
111
- try:
112
- module = __import__(module_name, fromlist=[entry])
113
- except ImportError as exc:
114
- available = _available()
115
- sys.stderr.write(
116
- f"qa_tool: {tool} is not bundled in this skill ({exc}).\n"
117
- f"This skill bundles: {', '.join(available) if available else 'nothing'}\n"
118
- )
119
- return 2
120
-
121
- return getattr(module, entry)(argv[1:])
122
-
123
-
124
- if __name__ == "__main__":
125
- # os.environ is untouched: the launcher never mutates the caller's environment.
126
- del os
127
- sys.exit(main())