@jesdi/skills 0.0.85 → 0.0.87
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.
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +13 -6
- package/skills/implement-spec/README.md +23 -11
- package/skills/implement-spec/SKILL.md +1 -1
- package/skills/implement-spec/driver.py +3 -2
- package/skills/implement-spec/driver_agents.py +93 -32
- package/skills/implement-spec/driver_run.py +23 -13
- package/skills/implement-spec/driver_state.py +1 -1
- package/skills/implement-spec/driver_summary.py +8 -1
- package/skills/implement-spec/tests/conftest.py +2 -0
- package/skills/implement-spec/tests/test_agents.py +56 -5
- package/skills/implement-spec/tests/test_arbitration.py +3 -1
- package/skills/implement-spec/tests/test_driver.py +2 -1
- package/skills/implement-spec/tests/test_landing.py +2 -2
- package/skills/implement-spec/tests/test_lenses.py +10 -5
- package/skills/implement-spec/tests/test_models.py +74 -0
- package/skills/implement-spec/tests/test_summary.py +8 -0
- package/skills/implement-spec/tests/test_walk.py +2 -2
- package/skills/test-weigh-in/dashboard.html +185 -27
- package/skills/test-weigh-in/rules.toml +18 -0
- package/skills/test-weigh-in/tests/browser_driver.py +161 -0
- package/skills/test-weigh-in/tests/conftest.py +8 -1
- package/skills/test-weigh-in/tests/latency_probe.py +96 -0
- package/skills/test-weigh-in/tests/layout_page.py +37 -0
- package/skills/test-weigh-in/tests/metric_page.py +56 -0
- package/skills/test-weigh-in/tests/overlap_page.py +60 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +3 -1
- package/skills/test-weigh-in/tests/sorted_map_page.py +35 -0
- package/skills/test-weigh-in/tests/test_brittleness.py +5 -0
- package/skills/test-weigh-in/tests/test_dashboard_layout.py +103 -0
- package/skills/test-weigh-in/tests/test_scoring.py +10 -0
- package/skills/test-weigh-in/weigh.py +25 -15
- package/skills/test-weigh-in/weigh_dashboard.py +9 -1
- package/skills/test-weigh-in/weigh_rules.py +3 -0
- package/skills-manifest.json +5 -5
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Ticket 04 of specs/test-weigh-in-dashboard-polish: readable layout, visible tabs and the offline report (R8, R9, R11, R12).
|
|
2
|
+
|
|
3
|
+
Seam: weigh_dashboard.write_dashboard (via layout_page.py, the real-suite fixture: 2,172 tests, 3,196 cases, 6,757 pairs).
|
|
4
|
+
The returned standalone HTML is opened from disk in Chrome with the network off (browser_driver.py, run by `uv run
|
|
5
|
+
--with playwright`, needs Chrome or a Playwright chromium) and its visible controls are driven. Latency is not asserted:
|
|
6
|
+
the 200 ms claim needs the benchmark machine the operator agrees (design.md).
|
|
7
|
+
"""
|
|
8
|
+
import json
|
|
9
|
+
import re
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import pytest
|
|
15
|
+
|
|
16
|
+
from fixture_repo import uv
|
|
17
|
+
|
|
18
|
+
HERE = Path(__file__).resolve().parent
|
|
19
|
+
SPEC = HERE.parents[2] / "specs" / "test-weigh-in-dashboard-polish"
|
|
20
|
+
TABS = ["Metrics", "Overlaps", "Map"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.fixture(scope="module")
|
|
24
|
+
def report(tmp_path_factory):
|
|
25
|
+
out = tmp_path_factory.mktemp("layout04")
|
|
26
|
+
built = subprocess.run([sys.executable, str(HERE / "layout_page.py"), str(out)], capture_output=True, text=True, timeout=600)
|
|
27
|
+
assert built.returncode == 0, built.stderr
|
|
28
|
+
html = Path(built.stdout.strip())
|
|
29
|
+
drove = subprocess.run([uv(), "run", "--with", "playwright", "python", str(HERE / "browser_driver.py"), str(html)],
|
|
30
|
+
capture_output=True, text=True, timeout=600)
|
|
31
|
+
assert drove.returncode == 0, drove.stderr[-3000:]
|
|
32
|
+
return {"bytes": html.stat().st_size, **json.loads(drove.stdout)}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def only_active(tabs, label):
|
|
36
|
+
"""Exactly one tab looks different from the rest, and it is `label`."""
|
|
37
|
+
sigs = [t["sig"] for t in tabs]
|
|
38
|
+
odd = [t["text"] for t in tabs if sigs.count(t["sig"]) == 1]
|
|
39
|
+
assert odd == [label], f"visibly active tabs: {odd}, selected {label}"
|
|
40
|
+
assert len({t["sig"] for t in tabs if t["text"] != label}) == 1, "the inactive tabs do not look alike"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_the_active_tab_follows_selection_and_keyboard_focus_shows(report):
|
|
44
|
+
for label in TABS:
|
|
45
|
+
only_active(report["tabs"]["steps"][label], label)
|
|
46
|
+
focus = report["tabs"]["focus"]
|
|
47
|
+
ring = not focus["outline"].startswith("none") and not focus["outline"].split()[1] == "0px"
|
|
48
|
+
assert ring or focus["sig_focused"] != focus["sig_unfocused"], f"no visible focus state: {focus}"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@pytest.mark.parametrize("view", ["desktop", "narrow"])
|
|
52
|
+
def test_gauges_align_and_partial_status_stays_readable(report, view):
|
|
53
|
+
gauges = report[view]["gauges"]
|
|
54
|
+
assert len(gauges) == 5
|
|
55
|
+
for g in gauges:
|
|
56
|
+
assert g["title"] and g["status"], "every gauge has a gauge-title and a gauge-status, a fully measured one too"
|
|
57
|
+
assert g["status"]["text"], "a fully measured pillar still states its measurement status"
|
|
58
|
+
assert not g["title"]["clipped"] and not g["status"]["clipped"]
|
|
59
|
+
assert g["status"]["font"] >= 11 and g["status"]["lines"] <= 2, f"partial status unreadable: {g['status']}"
|
|
60
|
+
rows = {}
|
|
61
|
+
for g in gauges:
|
|
62
|
+
rows.setdefault(g["card"]["top"], []).append(g)
|
|
63
|
+
for row in rows.values():
|
|
64
|
+
for part in ("title", "score", "status"):
|
|
65
|
+
assert len({g[part]["top"] for g in row}) == 1, f"{part} not aligned across a row at {view}: {[g[part]['top'] for g in row]}"
|
|
66
|
+
refactoring = next(g for g in gauges if "refactoring" in g["title"]["text"].lower())
|
|
67
|
+
assert "0 of 4" in refactoring["status"]["text"]
|
|
68
|
+
assert report[view]["overview"]["scroll_width"] <= report[view]["overview"]["viewport"], "the page overflows sideways"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.mark.parametrize("view", ["desktop", "narrow"])
|
|
72
|
+
def test_details_use_the_available_width_and_keep_full_identities(report, view):
|
|
73
|
+
r = report[view]
|
|
74
|
+
for key in ("feedback_details", "refactoring_details", "overlaps", "map"):
|
|
75
|
+
assert r[key]["scroll_width"] <= r[key]["viewport"], f"{key} overflows the viewport"
|
|
76
|
+
assert r[key]["details_right"] <= r[key]["viewport"]
|
|
77
|
+
assert r["feedback_table_share"] >= 0.85, "the metrics table leaves the right-hand region unused"
|
|
78
|
+
assert r["overlap_ids"]
|
|
79
|
+
for ident in r["overlap_ids"]:
|
|
80
|
+
assert ident["text"].endswith("x" * 40), "identity is not shown in full"
|
|
81
|
+
assert ident["right"] <= r["overlaps"]["viewport"] and not ident["clipped"] and not ident["ellipsis"]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_offline_from_disk_keeps_the_evidence(report):
|
|
85
|
+
j = report["journey"]
|
|
86
|
+
assert j["requests"] == [] and j["failed_requests"] == [] and j["page_errors"] == []
|
|
87
|
+
assert "No metrics were measured" in j["refactoring_text"] and "Total runtime" in j["feedback_text"]
|
|
88
|
+
assert "6,757" in j["count_all"] and j["first_row_page_1"] != j["first_row_page_2"]
|
|
89
|
+
assert re.search(r"\b1\b", j["count_search"]) and j["rows_search"] == 1 and "6,757" in j["count_cleared"]
|
|
90
|
+
assert j["dots"] == 2172 and "test_module_0010" in j["picked"] and j["similar_items"] > 0
|
|
91
|
+
assert "Anchors" in j["metrics_text"]
|
|
92
|
+
only_active(j["active_overlaps"], "Overlaps")
|
|
93
|
+
only_active(j["active_map"], "Map")
|
|
94
|
+
only_active(j["active_metrics"], "Metrics")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_the_size_of_the_real_suite_report_is_recorded_without_truncating_it(report):
|
|
98
|
+
record = (SPEC / "validation.md").read_text()
|
|
99
|
+
assert "2172 tests, 3196 cases, 6757 pairs" in record
|
|
100
|
+
recorded = int(re.search(r"html-bytes:\s*([\d,]+)", record).group(1).replace(",", ""))
|
|
101
|
+
assert report["bytes"] / 2 <= recorded <= report["bytes"] * 2, f"recorded {recorded}, this fixture renders {report['bytes']}"
|
|
102
|
+
assert report["bytes"] > 1_000_000
|
|
103
|
+
assert "6,757" in report["journey"]["count_all"] and report["journey"]["dots"] == 2172
|
|
@@ -101,6 +101,16 @@ def test_equal_anchors_stop_the_run_naming_the_metric(tmp_path, home, cache):
|
|
|
101
101
|
assert snapshots(home, KEY) == []
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
def test_a_metric_with_an_unknown_unit_stops_the_run_naming_the_metric(tmp_path, home, cache):
|
|
105
|
+
repo = build_repo(tmp_path / "demo")
|
|
106
|
+
rules = write_rules(tmp_path / "rules.toml")
|
|
107
|
+
rules.write_text(rules.read_text().replace('unit = "s"', 'unit = "min"', 1)) # the first "s" metric is total_runtime
|
|
108
|
+
result = weigh(repo, home, cache=cache, rules=rules)
|
|
109
|
+
assert result.returncode == 2
|
|
110
|
+
assert "total runtime needs a unit" in (result.stdout + result.stderr).lower()
|
|
111
|
+
assert snapshots(home, KEY) == []
|
|
112
|
+
|
|
113
|
+
|
|
104
114
|
def test_edited_rules_keep_the_version_and_change_the_hash(tmp_path, home, cache):
|
|
105
115
|
repo = build_repo(tmp_path / "demo")
|
|
106
116
|
before = write_rules(tmp_path / "before.toml", branch_coverage=dict(bad=50))
|
|
@@ -65,14 +65,23 @@ def main(argv=None):
|
|
|
65
65
|
"runtime_seconds": max(run["runtime_seconds"], sum(c["duration"] for c in run["cases"].values())),
|
|
66
66
|
}
|
|
67
67
|
values = feedback_values(tests, inventory["runtime_seconds"])
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
unmeasured = {}
|
|
69
|
+
|
|
70
|
+
def measure(mid, value, reason):
|
|
71
|
+
"""An optional metric records its value, or the reason it has none, here and only here."""
|
|
72
|
+
if value is None:
|
|
73
|
+
unmeasured[mid] = reason
|
|
74
|
+
else:
|
|
75
|
+
values[mid] = value
|
|
76
|
+
|
|
77
|
+
tier = "the mutation tier did not run"
|
|
78
|
+
measure("mutation_score", None if mutation is None else mutation["score"], tier)
|
|
79
|
+
measure("pseudo_tested_functions", None if mutation is None else mutation["pseudo_tested"], tier)
|
|
71
80
|
found, clusters = find_smells(repo, tests, violations(repo, rules.get("ruff", {}).get("pt", [])))
|
|
72
81
|
for node, info in found.items():
|
|
73
82
|
tests[node].update(info)
|
|
74
|
-
if inventory["source_lines"]
|
|
75
|
-
|
|
83
|
+
measure("test_source_ratio", inventory["test_lines"] / inventory["source_lines"] if inventory["source_lines"] else None,
|
|
84
|
+
"no source lines found")
|
|
76
85
|
# failing, erroring and skipped tests cost (runtime, lines, smells) but give no value: no coverage, overlap or uniqueness
|
|
77
86
|
covered = per_test(cov["report"], cov["arcs"], repo)
|
|
78
87
|
cov_tests = aggregate(cov["cases"])
|
|
@@ -84,18 +93,18 @@ def main(argv=None):
|
|
|
84
93
|
unique = unique_coverage(passing)
|
|
85
94
|
for node, test in tests.items():
|
|
86
95
|
test["unique_coverage"] = unique.get(node, 0)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if mutation is
|
|
90
|
-
values.update(kill_matrix(tests, passing, mutation))
|
|
96
|
+
measure("branch_coverage", branch_percent(cov["value_report"]), "no branch data in the coverage report")
|
|
97
|
+
# flags tests before the metrics they change are computed
|
|
98
|
+
measure("subsumed_in_kill_matrix", None if mutation is None else kill_matrix(tests, passing, mutation)["subsumed_in_kill_matrix"], tier)
|
|
91
99
|
values.update(smell_values(tests))
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
# a count-based metric is a percentage of all tests (req 17); only valued tests can lack unique coverage, and an
|
|
101
|
+
# insufficient-evidence test counts in no Economy metric
|
|
102
|
+
measure("no_unique_coverage",
|
|
103
|
+
100 * sum(not u and not tests[n].get("insufficient_evidence") for n, u in unique.items()) / len(tests) if passing else None,
|
|
104
|
+
"no test passed")
|
|
96
105
|
test_files = brittleness(repo, test_file_sources(tests))
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
measure("brittle_test_files", brittle_percent(test_files),
|
|
107
|
+
"no source file maps to a test file" if is_repo(repo) else "no git history")
|
|
99
108
|
metrics, pillars = score(rules, values, red=len(passing) < len(tests))
|
|
100
109
|
data = {
|
|
101
110
|
"commit": commit,
|
|
@@ -106,6 +115,7 @@ def main(argv=None):
|
|
|
106
115
|
"rules": {"version": rules["version"], "sha256": rules["sha256"]},
|
|
107
116
|
"inventory": inventory,
|
|
108
117
|
"metrics": metrics,
|
|
118
|
+
"unmeasured": unmeasured,
|
|
109
119
|
"pillars": pillars,
|
|
110
120
|
"mutation_settings": {"mutation": args.mutation, "matrix_per_function": "all" if args.matrix_per_function is None else args.matrix_per_function},
|
|
111
121
|
**({"mutation": {k: mutation[k] for k in ("sampled", "mutants", "matrix")}} if mutation is not None else {}),
|
|
@@ -18,6 +18,10 @@ def _failing(tests):
|
|
|
18
18
|
return sum(t["outcome"] == "failed" for t in tests.values())
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
def _failing_names(tests):
|
|
22
|
+
return [n for n, t in tests.items() if t["outcome"] == "failed"]
|
|
23
|
+
|
|
24
|
+
|
|
21
25
|
def _flaky(tests):
|
|
22
26
|
return sum(t.get("flaky", False) for t in tests.values())
|
|
23
27
|
|
|
@@ -31,6 +35,7 @@ def write_dashboard(home, data, rules):
|
|
|
31
35
|
failing = _failing(data["tests"])
|
|
32
36
|
page = {
|
|
33
37
|
"banner": f"{failing} tests are failing" if failing > 1 else "1 test is failing" if failing else None,
|
|
38
|
+
"failing": _failing_names(data["tests"]),
|
|
34
39
|
"skipped": [n for n, t in data["tests"].items() if t["outcome"] == "skipped"],
|
|
35
40
|
"insufficient": [n for n, t in data["tests"].items() if t.get("insufficient_evidence")],
|
|
36
41
|
"overlaps": data.get("overlaps", []),
|
|
@@ -39,7 +44,10 @@ def write_dashboard(home, data, rules):
|
|
|
39
44
|
"inventory": inventory_line(data["inventory"]),
|
|
40
45
|
"pillars": [
|
|
41
46
|
{"key": k, "name": p["name"], **data["pillars"][k],
|
|
42
|
-
"metrics": [{"name": m["name"],
|
|
47
|
+
"metrics": [{"name": m["name"], "unit": m["unit"], "target": m["target"], "bad": m["bad"], **data["metrics"][i]}
|
|
48
|
+
for i, m in p["metrics"].items() if i in data["metrics"]],
|
|
49
|
+
# an entry the snapshot does not record (older data) has no known cause
|
|
50
|
+
"missing": [{"name": m["name"], "reason": data.get("unmeasured", {}).get(i)} for i, m in p["metrics"].items() if i not in data["metrics"]],
|
|
43
51
|
"total": len(p["metrics"]),
|
|
44
52
|
"worst": worst_tests(data["tests"], k, _slow(rules)),
|
|
45
53
|
"smells": pillar_smells(data["tests"], PILLAR_SMELLS.get(k, ()))}
|
|
@@ -9,6 +9,7 @@ from weigh_env import SetupError
|
|
|
9
9
|
|
|
10
10
|
DEFAULT = Path(__file__).resolve().parent / "rules.toml"
|
|
11
11
|
TABLE = re.compile(r"^\[([A-Za-z0-9_.]+)\]$")
|
|
12
|
+
UNITS = ("%", "s", "") # percent of all tests, seconds, plain ratio
|
|
12
13
|
PILLARS = ("regression", "refactoring", "feedback", "maintainability", "economy")
|
|
13
14
|
|
|
14
15
|
|
|
@@ -58,6 +59,8 @@ def validate(rules):
|
|
|
58
59
|
if not pillar or not pillar.get("metrics"):
|
|
59
60
|
raise RulesError(f"rules.toml: pillar {key} is missing or has no metrics")
|
|
60
61
|
for mid, m in pillar["metrics"].items():
|
|
62
|
+
if m.get("unit") not in UNITS:
|
|
63
|
+
raise RulesError(f"rules.toml: {pillar['name']}: {m['name']} needs a unit, one of {', '.join(map(repr, UNITS))}")
|
|
61
64
|
if m["target"] == m["bad"]:
|
|
62
65
|
raise RulesError(f"rules.toml: {pillar['name']}: {m['name']} has target and bad anchors both {m['target']}")
|
|
63
66
|
total = sum(m["weight"] for m in pillar["metrics"].values())
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-05T18:12:03.162Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "implement-spec",
|
|
61
|
-
"version": "0.1.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.51",
|
|
62
|
+
"hash": "sha256-3ae7ce51a5d74ddd7161016275ff329636448471711b21fcdd742d345f181828",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"name": "test-weigh-in",
|
|
109
|
-
"version": "0.1.
|
|
110
|
-
"hash": "sha256-
|
|
109
|
+
"version": "0.1.3",
|
|
110
|
+
"hash": "sha256-aecabdc7fd3d511440930bdc3274960106fe37959227ae3be7428dd634f8d4eb",
|
|
111
111
|
"description": "Measure a Python/pytest suite and score it on five pillars (Protection against regressions, Resistance to refactoring, Fast feedback, Maintainability, Economy), writing a JSON snapshot and a static HTML dashboard. Read-only. Use when the user asks to weigh, measure or score their test suite."
|
|
112
112
|
},
|
|
113
113
|
{
|