unslop-design 1.11.0 → 1.12.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.
package/README.md CHANGED
@@ -212,6 +212,18 @@ python3 scripts/unslop-score.py examples/swiftui/after # 100/100
212
212
  The SwiftUI folders also hold the HTML mock of each state at iPhone size,
213
213
  the way quick mode shows a native before/after when there's no simulator.
214
214
 
215
+ ## Scores in the wild
216
+
217
+ Ran it on your own app or site? [Share the before/after and the
218
+ score](https://github.com/marcosnovo/unslop-design/issues/new?template=score-report.yml),
219
+ and it goes here with your permission: what the app is, the two numbers,
220
+ one image. What it missed is just as useful: that's how rules get added.
221
+
222
+ | App | Platform | Score | |
223
+ |---|---|---|---|
224
+ | [Refil](https://refil.app) (the author's) | iOS, Android | before/after above | [screens](#one-fix-at-a-time) |
225
+ | *Yours?* | | | [share it](https://github.com/marcosnovo/unslop-design/issues/new?template=score-report.yml) |
226
+
215
227
  ## Use it
216
228
 
217
229
  Type `/unslop-design` (or `$unslop-design` in Codex), or just ask in plain
@@ -289,23 +301,35 @@ clean, never changes code itself, and turns off with `UNSLOP_HOOK=off` or
289
301
  `hook: off` in `.unslop/context.md`.
290
302
 
291
303
  **On every pull request (GitHub Actions).** Each hit becomes an annotation
292
- on its line, the score goes to the job summary, and the job fails under your
293
- minimum:
304
+ on its line, and one comment on the PR keeps the score and the change
305
+ against the base branch, updated on every push:
306
+
307
+ > ### unslop score: 88/100 (+7 vs main)
308
+ > **Worse** · [#68] Border and shadow on one card: 0 → 2 (-2)
309
+ > **Better** · [#32] Colored glows: 3 → 0 (+8) · [#33] Emoji in the UI: 4 → 0 (+8)
310
+
311
+ The job fails under your minimum, if you set one:
294
312
 
295
313
  ```yaml
296
314
  # .github/workflows/unslop.yml
297
315
  on: pull_request
316
+ permissions:
317
+ contents: read
318
+ pull-requests: write # for the comment
298
319
  jobs:
299
320
  unslop:
300
321
  runs-on: ubuntu-latest
301
322
  steps:
302
- - uses: actions/checkout@v4
303
- - uses: marcosnovo/unslop-design@v1.11.0
323
+ - uses: actions/checkout@v5
324
+ - uses: marcosnovo/unslop-design@v1.12.0
304
325
  with:
305
326
  paths: src
306
- min: 80 # optional; also: allow, scale, type-scale
327
+ min: 80 # optional; also: allow, scale, type-scale, comment: false
307
328
  ```
308
329
 
330
+ Locally, `unslop-score.py --json > main.json` on one branch and
331
+ `--baseline main.json` on another gives the same comparison.
332
+
309
333
  **Anywhere else.** `python3 scripts/slop-scan.py src --github` prints the
310
334
  same annotations, `--json` every hit for other tools, and `--list-rules`
311
335
  every rule id. All of them read `.unslop/context.md`, so your scale and your
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unslop-design",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Make your app or site stop looking AI-generated: install the agent skill, scan UI code for slop and score it 0-100.",
5
5
  "license": "MIT",
6
6
  "author": "Marcos Novo (https://github.com/marcosnovo)",
@@ -3,7 +3,7 @@
3
3
 
4
4
  python3 scripts/unslop-score.py [paths…] [--audit unslop-audit/report.json]
5
5
  [--scale …] [--json | --markdown] [--min 80]
6
- [--save [.unslop]]
6
+ [--save [.unslop]] [--baseline base.json]
7
7
 
8
8
  Scores the source with the same rules as `slop-scan.py` and, if you pass a
9
9
  `web-audit.mjs` report, the rendered page too (scroll, contrast, focus,
@@ -13,7 +13,9 @@ are left more than how big the codebase is. Prints the breakdown and a
13
13
  README badge. With --min it exits 1 below that score (pre-commit hook).
14
14
  With --save it appends the run to .unslop/history.json and prints the
15
15
  trend ("score 41 → 88 → 91"); --markdown prints a table for a PR comment or
16
- a GitHub Actions job summary.
16
+ a GitHub Actions job summary. --baseline compares with an earlier --json
17
+ run (the base branch in a PR): "score 72 → 81 (+9)", what got better and what
18
+ got worse.
17
19
 
18
20
  It is a smoke alarm, not a judge: a 95 can still have a flat hierarchy,
19
21
  and a gradient you chose on purpose costs points anyway (silence that line
@@ -179,6 +181,26 @@ def save_run(folder, run):
179
181
  return [h["score"] for h in history]
180
182
 
181
183
 
184
+ def compare(base, score, lines):
185
+ """Score delta and per-row changes against an earlier --json output."""
186
+ before = {r["rule"]: (r["count"], r["points"]) for r in base.get("penalties", [])}
187
+ now = {r: (n, p) for p, r, n in lines}
188
+ better, worse = [], []
189
+ for rule in sorted(set(before) | set(now)):
190
+ (bn, bp), (nn, np_) = before.get(rule, (0, 0)), now.get(rule, (0, 0))
191
+ if np_ < bp:
192
+ better.append({"rule": rule, "from": bn, "to": nn, "points": round(bp - np_, 1)})
193
+ elif np_ > bp:
194
+ worse.append({"rule": rule, "from": bn, "to": nn, "points": round(np_ - bp, 1)})
195
+ better.sort(key=lambda x: -x["points"])
196
+ worse.sort(key=lambda x: -x["points"])
197
+ return {"score": base["score"], "delta": score - base["score"], "better": better, "worse": worse}
198
+
199
+
200
+ def signed(n):
201
+ return f"+{n:g}" if n > 0 else f"{n:g}" if n < 0 else "±0"
202
+
203
+
182
204
  def main():
183
205
  ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
184
206
  ap.add_argument("paths", nargs="*", help="source to scan (default: . unless only --audit is given)")
@@ -189,6 +211,8 @@ def main():
189
211
  ap.add_argument("--save", nargs="?", const=".unslop", metavar="DIR",
190
212
  help="append this run to DIR/history.json (default .unslop) and show the trend")
191
213
  ap.add_argument("--min", type=float, help="exit 1 below this score")
214
+ ap.add_argument("--baseline", metavar="JSON", help="an earlier --json output to compare with (e.g. the base branch)")
215
+ ap.add_argument("--baseline-label", default="baseline", metavar="NAME", help="what to call it (e.g. main)")
192
216
  ap.add_argument("--type-scale", help="allowed font sizes in px (default: the project context, else slop-scan's)")
193
217
  ap.add_argument("--context", metavar="FILE", help="project context to read (default .unslop/context.md if present)")
194
218
  ap.add_argument("--no-context", action="store_true", help="ignore .unslop/context.md")
@@ -255,12 +279,34 @@ def main():
255
279
  scores = save_run(a.save, {"score": score, "files": files, "audit": bool(a.audit), "allowed": allowed,
256
280
  "penalties": [{"rule": r, "count": n, "points": p} for p, r, n in lines]})
257
281
  trend = " → ".join(str(s) for s in scores[-5:])
282
+ cmp_ = None
283
+ if a.baseline:
284
+ try:
285
+ with open(a.baseline, encoding="utf-8") as fh:
286
+ cmp_ = compare(json.load(fh), score, lines)
287
+ except (OSError, ValueError, KeyError) as e:
288
+ sys.exit(f"can't read the baseline {a.baseline}: {e}. It is the --json output of an earlier run.")
258
289
  if a.markdown:
259
- out = [f"### unslop score: {score}/100 ({word})", ""]
290
+ if cmp_:
291
+ out = [f"### unslop score: {score}/100 ({signed(cmp_['delta'])} vs {a.baseline_label})", "",
292
+ f"{a.baseline_label} {cmp_['score']} → this change {score}", ""]
293
+ for title, rows, sign in (("Worse", cmp_["worse"], "-"), ("Better", cmp_["better"], "+")):
294
+ if rows:
295
+ out.append(f"**{title}**")
296
+ out += [f"- {r['rule']}: {r['from']} → {r['to']} ({sign}{r['points']:g})" for r in rows]
297
+ out.append("")
298
+ if not cmp_["better"] and not cmp_["worse"]:
299
+ out += ["No change in any row.", ""]
300
+ if lines:
301
+ out += ["<details><summary>Every row now</summary>", ""]
302
+ else:
303
+ out = [f"### unslop score: {score}/100 ({word})", ""]
260
304
  if trend and "→" in trend:
261
305
  out += [f"Trend: {trend}", ""]
262
306
  if lines:
263
307
  out += ["| Points | Fix | Hits |", "|---:|---|---:|"] + [f"| -{p:g} | {r} | {n} |" for p, r, n in lines]
308
+ if cmp_:
309
+ out += ["", "</details>"]
264
310
  else:
265
311
  out.append("Nothing found.")
266
312
  if allowed:
@@ -270,7 +316,7 @@ def main():
270
316
  elif a.json:
271
317
  print(json.dumps({"score": score, "verdict": word, "files": files, "audit": bool(a.audit), "badge": badge,
272
318
  "penalties": [{"rule": r, "count": n, "points": p} for p, r, n in lines],
273
- "allowed": allowed, "trend": trend}, indent=2))
319
+ "allowed": allowed, "trend": trend, "baseline": cmp_}, indent=2))
274
320
  else:
275
321
  src = []
276
322
  if paths:
@@ -282,6 +328,11 @@ def main():
282
328
  print(f"unslop score: {score}/100 — {word} ({' + '.join(src)})")
283
329
  if trend and "→" in trend:
284
330
  print(f"trend: {trend} ({os.path.join(a.save, 'history.json')})")
331
+ if cmp_:
332
+ print(f"vs {a.baseline_label}: {cmp_['score']} → {score} ({signed(cmp_['delta'])})")
333
+ for title, rows, sign in (("worse", cmp_["worse"], "-"), ("better", cmp_["better"], "+")):
334
+ for r in rows:
335
+ print(f" {title}: {r['rule']} {r['from']} → {r['to']} ({sign}{r['points']:g})")
285
336
  if allowed:
286
337
  print("allowed by the project (--allow, not scored): " + ", ".join(allowed))
287
338
  if lines: