jekyll-theme-zer0 1.28.0 → 1.29.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +430 -13
  3. data/_data/backlog.yml +356 -2
  4. data/_data/consumers.yml +109 -4
  5. data/_data/features.yml +157 -0
  6. data/_data/i18n/fr.yml +12 -7
  7. data/_data/i18n/manifest.yml +39 -12
  8. data/_data/ingredient_densities.yml +122 -0
  9. data/_data/navigation/main.yml +16 -0
  10. data/_data/recipe_courses.yml +64 -0
  11. data/_data/theme-manifest.yml +68 -40
  12. data/_data/ui-text.yml +8 -0
  13. data/_includes/README.md +15 -1
  14. data/_includes/components/background-customizer.html +2 -2
  15. data/_includes/components/cookie-consent.html +4 -4
  16. data/_includes/components/info-section.html +8 -3
  17. data/_includes/components/language-toggle.html +168 -21
  18. data/_includes/components/page-views-init.html +55 -0
  19. data/_includes/components/page-views.html +33 -0
  20. data/_includes/components/recipe-card.html +67 -0
  21. data/_includes/components/recipe-duration.html +50 -0
  22. data/_includes/components/recipe-grams.html +58 -0
  23. data/_includes/components/recipe-index.html +96 -0
  24. data/_includes/components/recipe-ingredients.html +90 -0
  25. data/_includes/components/recipe-meta.html +96 -0
  26. data/_includes/components/recipe-nutrition.html +57 -0
  27. data/_includes/components/recipe-qty.html +73 -0
  28. data/_includes/components/recipe-ratio.html +151 -0
  29. data/_includes/components/recipe-scaler.html +73 -0
  30. data/_includes/components/recipe-steps.html +86 -0
  31. data/_includes/components/recipe-temp.html +45 -0
  32. data/_includes/components/search-modal.html +2 -2
  33. data/_includes/components/shortcuts-modal.html +3 -0
  34. data/_includes/components/theme-info.html +8 -1
  35. data/_includes/content/jsonld-software.html +22 -3
  36. data/_includes/core/footer.html +18 -16
  37. data/_includes/core/head.html +12 -0
  38. data/_includes/core/header.html +7 -4
  39. data/_includes/navigation/section-sidebar.html +93 -11
  40. data/_includes/navigation/sidebar-left.html +2 -1
  41. data/_includes/navigation/sidebar-right.html +2 -1
  42. data/_includes/setup/wizard.html +173 -86
  43. data/_includes/stats/stats-metrics.html +2 -2
  44. data/_layouts/README.md +2 -0
  45. data/_layouts/admin.html +2 -2
  46. data/_layouts/article.html +5 -0
  47. data/_layouts/cookbook.html +88 -0
  48. data/_layouts/default.html +4 -4
  49. data/_layouts/recipe.html +274 -0
  50. data/_layouts/root.html +22 -3
  51. data/_layouts/section.html +39 -10
  52. data/_sass/components/_callout.scss +1 -1
  53. data/_sass/components/_footer.scss +37 -1
  54. data/_sass/components/_page-views.scss +36 -0
  55. data/_sass/components/_recipe.scss +506 -0
  56. data/_sass/components/_setup-wizard.scss +235 -0
  57. data/_sass/components/_ui-enhancements.scss +6 -6
  58. data/_sass/core/_navbar.scss +250 -15
  59. data/_sass/layouts/_landing.scss +2 -2
  60. data/_sass/tokens/_color.scss +6 -0
  61. data/_sass/tokens/_index.scss +2 -0
  62. data/_sass/tokens/_radius.scss +21 -0
  63. data/_sass/tokens/_typography.scss +4 -0
  64. data/_sass/utilities/_focus.scss +14 -0
  65. data/assets/css/main.scss +3 -0
  66. data/assets/js/modules/navigation/navbar.js +55 -0
  67. data/assets/js/page-views.js +372 -0
  68. data/assets/js/recipe-scaler.js +501 -0
  69. data/assets/js/search-modal.js +10 -0
  70. data/assets/js/setup-wizard.js +322 -20
  71. data/scripts/README.md +29 -0
  72. data/scripts/bin/audit-consumer +39 -7
  73. data/scripts/bin/giscus-discussions +213 -14
  74. data/scripts/bin/manifest +35 -12
  75. data/scripts/ci/agent_review_result.py +164 -0
  76. data/scripts/ci/test_agent_review_result.py +172 -0
  77. data/scripts/design-system-check.rb +170 -0
  78. data/scripts/lib/audit.sh +42 -2
  79. data/scripts/lint-liquid-raw.rb +137 -0
  80. data/scripts/test/lib/run_tests.sh +2 -1
  81. data/scripts/test/lib/test_agent_review_result.sh +27 -0
  82. data/scripts/translate.rb +71 -15
  83. metadata +31 -2
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env python3
2
+ """Unit tests for scripts/ci/agent_review_result.py (issue #418).
3
+
4
+ The bug these guard against: the Claude tier of ai-content-review.yml posted
5
+
6
+ Failed to authenticate. API Error: 401 OAuth access token has been revoked.
7
+
8
+ into PR #414 as its review, and the job still reported success. The credential
9
+ has since been rotated, but the SWALLOW is the durable defect — it would hide
10
+ the next revoked token exactly as well as it hid this one.
11
+
12
+ The first fixture below is that output verbatim, copied from the comment the
13
+ workflow actually posted (2026-08-23T04:51:47Z, run 32618860829). If the guard
14
+ ever stops failing on it, the regression is back.
15
+
16
+ Both directions are covered. A real review must NOT be flagged — including one
17
+ whose prose legitimately quotes an auth error, which is the false positive a
18
+ bare `grep 'Failed to authenticate'` would produce (and which would fire on this
19
+ repo's own troubleshooting docs).
20
+
21
+ Dependency-light on purpose: standard library only, so it runs anywhere the
22
+ workflow does.
23
+
24
+ python3 scripts/ci/test_agent_review_result.py
25
+ """
26
+
27
+ from __future__ import annotations
28
+
29
+ import re
30
+ import sys
31
+ import tempfile
32
+ from pathlib import Path
33
+
34
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
35
+
36
+ import agent_review_result as arr # noqa: E402
37
+
38
+ REPO_ROOT = Path(__file__).resolve().parents[2]
39
+ WORKFLOW = REPO_ROOT / ".github" / "workflows" / "ai-content-review.yml"
40
+
41
+ CHECKS: list[tuple[str, bool]] = []
42
+
43
+
44
+ def check(label: str, ok: bool) -> None:
45
+ CHECKS.append((label, bool(ok)))
46
+
47
+
48
+ # The 401 exactly as the CLI printed it and the workflow posted it.
49
+ AUTH_401 = "Failed to authenticate. API Error: 401 OAuth access token has been revoked.\n"
50
+
51
+ REAL_REVIEW = """**Verdict:** approve with minor suggestions
52
+
53
+ ### pages/_docs/getting-started.md
54
+
55
+ - The `description` front matter reads as a keyword list rather than a sentence.
56
+ Rewrite it as prose so search snippets are readable.
57
+ - The second H2 duplicates the page title; demote it to an H3 or cut it.
58
+ - Two code fences are missing a language tag, so they render unhighlighted.
59
+ - Alt text on the architecture diagram describes the file, not the picture.
60
+
61
+ ### pages/_docs/configuration.md
62
+
63
+ - Consistent terminology: this page says "config file" where the rest of the
64
+ docs say `_config.yml`. Pick one.
65
+ - The table of collection defaults is missing the `books` collection added in
66
+ v1.19, so the page is incomplete rather than merely terse.
67
+ - Sentence length in "Advanced overrides" averages 38 words; split the longest.
68
+
69
+ ### Summary
70
+
71
+ Both files are accurate and well-organised. The findings above are polish, not
72
+ correctness — nothing here blocks the merge.
73
+ """
74
+
75
+ # A real review that TALKS about auth failures. Must not be mistaken for one.
76
+ REVIEW_ABOUT_AUTH = """**Verdict:** approve
77
+
78
+ ### docs/troubleshooting/credentials.md
79
+
80
+ - The page explains what to do when the CLI prints "Failed to authenticate. API
81
+ Error: 401 OAuth access token has been revoked." — good, that is the exact
82
+ string users will search for, so keep it verbatim rather than paraphrasing.
83
+ - Add a cross-link to the rotation runbook; the reader is told to "rotate the
84
+ token" with no pointer to how.
85
+ - The `authentication_error` example block is missing a language tag.
86
+ - Consider noting that the deterministic review tier keeps working while the
87
+ credential is broken, since that surprised at least one reader.
88
+ - Front matter `lastmod` is stale by two releases.
89
+
90
+ ### Summary
91
+
92
+ Accurate and genuinely useful. Only polish items above; the troubleshooting
93
+ steps themselves check out against the current workflow definition.
94
+ """
95
+
96
+
97
+ def run_guard(status: int, stdout: str, stderr: str = "") -> tuple[int, str]:
98
+ """Invoke the guard end-to-end; return (exit code, comment body)."""
99
+ with tempfile.TemporaryDirectory() as tmp:
100
+ d = Path(tmp)
101
+ (d / "out.txt").write_text(stdout, encoding="utf-8")
102
+ (d / "err.txt").write_text(stderr, encoding="utf-8")
103
+ rc = arr.main([
104
+ "--status", str(status),
105
+ "--stdout", str(d / "out.txt"),
106
+ "--stderr", str(d / "err.txt"),
107
+ "--out", str(d / "body.md"),
108
+ ])
109
+ return rc, (d / "body.md").read_text(encoding="utf-8")
110
+
111
+
112
+ def main() -> int:
113
+ # --- the observed failure, verbatim ------------------------------------ #
114
+ rc, body = run_guard(0, AUTH_401)
115
+ check("the verbatim PR #414 401 fails the step (exit 1) even on claude exit 0", rc == 1)
116
+ check("the 401 comment body says the review did not run", "did not run" in body)
117
+ check("the raw 401 line is no longer posted as if it were the review",
118
+ not body.startswith(f"{arr.TITLE}\n\nFailed to authenticate"))
119
+ check("the failure notice is visibly a caution, not a review", "[!CAUTION]" in body)
120
+
121
+ rc, _ = run_guard(1, AUTH_401)
122
+ check("a non-zero claude exit fails the step", rc == 1)
123
+
124
+ # --- nothing came back -------------------------------------------------- #
125
+ rc, body = run_guard(0, "")
126
+ check("empty agent output fails the step", rc == 1)
127
+ check("the empty-output notice names the reason", "no output" in body)
128
+
129
+ rc, _ = run_guard(0, "\n \n\t\n")
130
+ check("whitespace-only agent output fails the step", rc == 1)
131
+
132
+ # --- other credential failures ------------------------------------------ #
133
+ rc, _ = run_guard(0, "API Error: 400 Credit balance is too low to access the API.\n")
134
+ check("a credit-balance failure fails the step", rc == 1)
135
+ rc, _ = run_guard(0, "Invalid API key · Please run `claude login`\n")
136
+ check("an invalid-key failure fails the step", rc == 1)
137
+ rc, _ = run_guard(0, "API Error: 429 rate limit exceeded\n")
138
+ check("a rate-limit failure fails the step", rc == 1)
139
+
140
+ # --- real reviews pass --------------------------------------------------- #
141
+ rc, body = run_guard(0, REAL_REVIEW)
142
+ check("a genuine multi-section review passes", rc == 0)
143
+ check("the real review is posted under the review heading", "**Verdict:**" in body)
144
+
145
+ rc, _ = run_guard(0, REVIEW_ABOUT_AUTH)
146
+ check("a long review that QUOTES an auth error is not mistaken for a failure", rc == 0)
147
+
148
+ # --- the workflow actually uses the guard -------------------------------- #
149
+ # Without this the fix is one deleted line away from returning, and nothing
150
+ # in the fixture tests above would notice.
151
+ wf = WORKFLOW.read_text(encoding="utf-8")
152
+ check("ai-content-review.yml invokes the guard",
153
+ "scripts/ci/agent_review_result.py" in wf)
154
+ check("the agent step no longer ends by piping stdout into the comment body",
155
+ not re.search(r"cat /tmp/agent-review\.md\s*\n\s*\}\s*>\s*/tmp/agent-review-final\.md", wf))
156
+ check("the AI gate no longer implies a present credential is a working one",
157
+ "not validity" in wf)
158
+
159
+ failed = [label for label, ok in CHECKS if not ok]
160
+ print()
161
+ for label, ok in CHECKS:
162
+ print(f" {'PASS' if ok else 'FAIL'} {label}")
163
+ print()
164
+ if failed:
165
+ print(f"FAILED ({len(failed)}/{len(CHECKS)})")
166
+ return 1
167
+ print(f"OK ({len(CHECKS)} checks)")
168
+ return 0
169
+
170
+
171
+ if __name__ == "__main__":
172
+ raise SystemExit(main())
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env ruby
2
+ # Feature: ZER0-081
3
+ # frozen_string_literal: true
4
+
5
+ # ---------------------------------------------------------------------------
6
+ # design-system-check — token parity between the theme and its Claude Design
7
+ # mirror.
8
+ #
9
+ # The `--zer0-*` design tokens live twice on purpose:
10
+ # - `_sass/tokens/*.scss` — the source of truth the theme compiles
11
+ # - `_design-system/tokens/*.css` — the mirror pushed to the Claude Design
12
+ # project (see _design-system/SYNC.md)
13
+ #
14
+ # This check keeps the two in lockstep so the design system can be built from
15
+ # either side without silent drift:
16
+ #
17
+ # 1. Per file pair: the sets of `--zer0-*` names must match, and every value
18
+ # must resolve to the same string. `var(--x, fallback)` wrappers are
19
+ # resolved against the mirror's concrete `--bs-*`/`--bd-*` primitives, so
20
+ # the theme's alias form and the mirror's self-contained form compare
21
+ # equal.
22
+ # 2. Skins: `_sass/theme/_skins.scss` and `tokens/skins.css` must declare the
23
+ # same skin names, and each mirror skin's brand hex must appear in the
24
+ # matching SCSS block.
25
+ # 3. Dangling-token audit: any fallback-less `var(--zer0-…)` reference in
26
+ # `_sass/` must be declared somewhere (tokens, includes, or JS).
27
+ #
28
+ # ruby scripts/design-system-check.rb # exit 1 + report on drift
29
+ #
30
+ # Runs in the `core` test suite (test/test_core.sh). Plain Ruby, no gems.
31
+ # ---------------------------------------------------------------------------
32
+
33
+ ROOT = File.expand_path('..', __dir__)
34
+
35
+ PAIRS = {
36
+ '_sass/tokens/_color.scss' => '_design-system/tokens/colors.css',
37
+ '_sass/tokens/_spacing.scss' => '_design-system/tokens/spacing.css',
38
+ '_sass/tokens/_radius.scss' => '_design-system/tokens/radius.css',
39
+ '_sass/tokens/_typography.scss' => '_design-system/tokens/typography.css',
40
+ '_sass/tokens/_shadow.scss' => '_design-system/tokens/shadows.css',
41
+ '_sass/tokens/_motion.scss' => '_design-system/tokens/motion.css',
42
+ '_sass/tokens/_breakpoints.scss' => '_design-system/tokens/breakpoints.css',
43
+ '_sass/tokens/_layers.scss' => '_design-system/tokens/layers.css'
44
+ }.freeze
45
+
46
+ SKIN_SCSS = '_sass/theme/_skins.scss'
47
+ SKIN_CSS = '_design-system/tokens/skins.css'
48
+
49
+ def read(rel)
50
+ path = File.join(ROOT, rel)
51
+ abort "design-system-check: missing file #{rel}" unless File.file?(path)
52
+ File.read(path)
53
+ end
54
+
55
+ # Strip /* */ blocks, // line comments, and everything from the first @media on
56
+ # (motion files re-declare durations under prefers-reduced-motion).
57
+ def strip(text, scss:)
58
+ t = text.split('@media', 2).first
59
+ t = t.gsub(%r{/\*.*?\*/}m, '')
60
+ t = t.gsub(%r{(?:^|\s)//.*$}, '') if scss
61
+ t
62
+ end
63
+
64
+ # { '--zer0-foo' => 'raw value', ... } from declaration-position matches.
65
+ def declarations(text)
66
+ text.scan(/(--zer0-[\w-]+)\s*:\s*([^;]+);/).each_with_object({}) do |(k, v), h|
67
+ h[k] ||= v.strip.gsub(/\s+/, ' ')
68
+ end
69
+ end
70
+
71
+ # All custom properties (any prefix) declared in the mirror's colors.css light
72
+ # scope — the concrete primitives var() chains resolve against.
73
+ def primitives
74
+ light = read(SKIN_CSS.sub('skins', 'colors')).split('[data-bs-theme="dark"]', 2).first
75
+ strip(light, scss: false).scan(/(--[\w-]+)\s*:\s*([^;]+);/)
76
+ .each_with_object({}) { |(k, v), h| h[k] ||= v.strip.gsub(/\s+/, ' ') }
77
+ end
78
+
79
+ # Resolve a value that is entirely a var() wrapper: prefer the primitive's
80
+ # concrete value, else the wrapper's own fallback. Inner var() references in
81
+ # composite values (color-mix, rgba) are left as-is and compared literally.
82
+ def resolve(value, prims, depth = 0)
83
+ v = value.strip.gsub(/\s+/, ' ')
84
+ return v if depth > 6
85
+
86
+ m = v.match(/\Avar\((--[\w-]+)(?:\s*,\s*(.+))?\)\z/)
87
+ return v unless m
88
+
89
+ name, fallback = m[1], m[2]
90
+ if prims.key?(name)
91
+ resolve(prims[name], prims, depth + 1)
92
+ elsif fallback
93
+ resolve(fallback, prims, depth + 1)
94
+ else
95
+ v
96
+ end
97
+ end
98
+
99
+ failures = []
100
+ prims = primitives
101
+
102
+ # --- 1. token parity per file pair -----------------------------------------
103
+ PAIRS.each do |scss_rel, css_rel|
104
+ scss = declarations(strip(read(scss_rel), scss: true))
105
+ css = declarations(strip(read(css_rel), scss: false))
106
+
107
+ (scss.keys - css.keys).each { |k| failures << "#{css_rel}: missing #{k} (declared in #{scss_rel})" }
108
+ (css.keys - scss.keys).each { |k| failures << "#{scss_rel}: missing #{k} (declared in #{css_rel})" }
109
+
110
+ (scss.keys & css.keys).each do |k|
111
+ a = resolve(scss[k], prims)
112
+ b = resolve(css[k], prims)
113
+ failures << "#{k}: theme resolves to `#{a}` but mirror to `#{b}`" unless a == b
114
+ end
115
+ end
116
+
117
+ # Both motion files must keep the reduced-motion guard.
118
+ [PAIRS.key('_design-system/tokens/motion.css'), '_design-system/tokens/motion.css'].each do |rel|
119
+ failures << "#{rel}: lost its prefers-reduced-motion guard" unless read(rel).include?('prefers-reduced-motion')
120
+ end
121
+
122
+ # --- 2. skins: same names, same brand hex ----------------------------------
123
+ scss_skins_src = read(SKIN_SCSS)
124
+ css_skins_src = read(SKIN_CSS)
125
+ scss_skins = scss_skins_src.scan(/\[data-theme-skin="(\w+)"\]/).flatten.uniq.sort
126
+ css_skins = css_skins_src.scan(/\[data-theme-skin="(\w+)"\]/).flatten.uniq.sort
127
+ unless scss_skins == css_skins
128
+ failures << "skins differ: theme has #{scss_skins.join(', ')} but mirror has #{css_skins.join(', ')}"
129
+ end
130
+
131
+ (scss_skins & css_skins).each do |skin|
132
+ block = css_skins_src[/\[data-theme-skin="#{skin}"\]\s*\{.*?\}/m].to_s
133
+ hex = block[/--zer0-color-primary:\s*(#\h+)/, 1]
134
+ next unless hex
135
+
136
+ scss_block = scss_skins_src[/\[data-theme-skin="#{skin}"\]\s*\{.*?\}/m].to_s
137
+ unless scss_block.downcase.include?(hex.downcase)
138
+ failures << "skin #{skin}: mirror brand #{hex} not found in #{SKIN_SCSS}"
139
+ end
140
+ end
141
+
142
+ # --- 3. dangling-token audit ------------------------------------------------
143
+ declared = Dir.glob(File.join(ROOT, '_sass/**/*.scss'))
144
+ .flat_map { |f| File.read(f).scan(/(--zer0-[\w-]+)\s*:/) }.flatten
145
+ declared += Dir.glob(File.join(ROOT, '{_includes,_layouts}/**/*.html'))
146
+ .flat_map { |f| File.read(f).scan(/(--zer0-[\w-]+)\s*:/) }.flatten
147
+ declared += Dir.glob(File.join(ROOT, 'assets/js/**/*.js')).flat_map do |f|
148
+ src = File.read(f)
149
+ src.scan(/setProperty\(\s*['"](--zer0-[\w-]+)/).flatten +
150
+ src.scan(/['"`](--zer0-[\w-]+)['"`:]/).flatten
151
+ end
152
+ declared = declared.uniq
153
+
154
+ Dir.glob(File.join(ROOT, '_sass/**/*.scss')).sort.each do |f|
155
+ File.read(f).scan(/var\(\s*(--zer0-[\w-]+)\s*\)/).flatten.uniq.each do |token|
156
+ next if declared.include?(token)
157
+
158
+ failures << "#{f.sub("#{ROOT}/", '')}: references #{token} with no fallback, but it is never declared"
159
+ end
160
+ end
161
+
162
+ # --- report -----------------------------------------------------------------
163
+ if failures.empty?
164
+ puts "design-system-check: OK — #{PAIRS.size} token file pairs, #{css_skins.size} skins, no dangling tokens"
165
+ else
166
+ warn "design-system-check: #{failures.size} problem(s) — theme (_sass/tokens) and mirror (_design-system/tokens) have drifted:"
167
+ failures.each { |f| warn " - #{f}" }
168
+ warn 'Fix the drift (see _design-system/SYNC.md), then re-run: ruby scripts/design-system-check.rb'
169
+ exit 1
170
+ end
data/scripts/lib/audit.sh CHANGED
@@ -205,13 +205,45 @@ detect_consumer_mode() {
205
205
  return
206
206
  fi
207
207
 
208
- if grep -qE '^remote_theme:' "$config"; then
208
+ # Match a top-level `remote_theme` key. The whitespace class before the
209
+ # colon is load-bearing: most fleet consumers write column-aligned YAML
210
+ # (`remote_theme : "bamr87/zer0-mistakes"`), which a bare
211
+ # `^remote_theme:` never matches — every one of them was silently
212
+ # misreported as gem mode, skipping the plugin checks entirely.
213
+ # `|| true` keeps a no-match grep from tripping the caller's `set -o pipefail`.
214
+ local line value
215
+ line=$(grep -m1 -E '^remote_theme[[:space:]]*:' "$config" 2>/dev/null || true)
216
+ value=$(printf '%s' "$line" \
217
+ | sed -E 's/^remote_theme[[:space:]]*:[[:space:]]*//; s/[[:space:]]*(#.*)?$//; s/^"(.*)"$/\1/; s/^'\''(.*)'\''$/\1/')
218
+
219
+ # `remote_theme: false` (or an empty value) is how a consumer turns the
220
+ # remote theme OFF and resolves the theme as a gem instead.
221
+ if [[ -n "$value" && "$value" != "false" ]]; then
209
222
  echo "remote_theme"
210
223
  else
211
224
  echo "gem"
212
225
  fi
213
226
  }
214
227
 
228
+ # detect_consumer_source <consumer_root>
229
+ # Echoes the Jekyll `source:` value from _config.yml (relative path), or empty.
230
+ #
231
+ # Jekyll's `source:` relocates the whole site tree — zer0-pages keeps every
232
+ # theme-shadowing file under `pages/`. Auditing the repo root there reports a
233
+ # falsely clean "0 overrides, 0 unique files"; the real surface only appears
234
+ # when the scan follows `source:`.
235
+ detect_consumer_source() {
236
+ local consumer_root="$1"
237
+ local config="$consumer_root/_config.yml"
238
+
239
+ [[ -f "$config" ]] || return 0
240
+
241
+ local line
242
+ line=$(grep -m1 -E '^source[[:space:]]*:' "$config" 2>/dev/null || true)
243
+ printf '%s' "$line" \
244
+ | sed -E 's/^source[[:space:]]*:[[:space:]]*//; s/[[:space:]]*(#.*)?$//; s/^"(.*)"$/\1/; s/^'\''(.*)'\''$/\1/; s#^\./##; s#/$##'
245
+ }
246
+
215
247
  # ---------------------------------------------------------------------------
216
248
  # Output helpers
217
249
  # ---------------------------------------------------------------------------
@@ -277,7 +309,15 @@ print_classification() {
277
309
  echo "::notice file=$relpath::OPTIONAL_PLUGIN (not required)" ;;
278
310
  esac
279
311
  elif [[ "$format" == "json" ]]; then
280
- echo " {\"path\":\"$relpath\",\"status\":\"$classification\"},"
312
+ # Separator goes BEFORE each entry but the first, so the array never
313
+ # ends on a dangling comma. Emitting a trailing comma per entry (the
314
+ # previous behaviour) produced `...},\n]}` — which no JSON parser
315
+ # accepts, making --format json unusable for any CI consumer.
316
+ if [[ "${JSON_ENTRY_EMITTED:-0}" == "1" ]]; then
317
+ printf ',\n'
318
+ fi
319
+ JSON_ENTRY_EMITTED=1
320
+ printf ' {"path":"%s","status":"%s"}' "$relpath" "$classification"
281
321
  else
282
322
  echo -e "${color}[$classification]${NC} $relpath"
283
323
  fi
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # ---------------------------------------------------------------------------
5
+ # lint-liquid-raw — guard the Markdown the Pages build renders through Liquid
6
+ #
7
+ # `github-pages` ships jekyll-optional-front-matter, so EVERY non-excluded
8
+ # Markdown file in the repo becomes a page — CHANGELOG.md and the
9
+ # _design-system/ mirror included — and every one of them is run through Liquid
10
+ # before Markdown. Two failure modes follow, and neither is loud:
11
+ #
12
+ # 1. An unbalanced `{% raw %}`. Liquid's raw block swallows everything up to
13
+ # the FIRST `{% endraw %}`, so a stray opener silently eats the rest of the
14
+ # document. CHANGELOG.md carried one that consumed 945 lines while the
15
+ # build stayed green.
16
+ #
17
+ # 2. A literal `{% raw %}` / `{% endraw %}` written as documentation prose.
18
+ # It reads like text but parses as a tag, which is how (1) happens. To show
19
+ # the tag, escape it: `{% raw %}{% raw %}{% endraw %}`.
20
+ #
21
+ # A Liquid *syntax* error (e.g. `{{…}}`) is caught by the Pages workflow, which
22
+ # fails on "Liquid Warning" in the build output. This script catches the class
23
+ # the build cannot report, because swallowed text is not an error to Liquid.
24
+ #
25
+ # Usage:
26
+ # scripts/lint-liquid-raw.rb # scan the rendered Markdown surface
27
+ # scripts/lint-liquid-raw.rb PATH... # scan specific files
28
+ # scripts/lint-liquid-raw.rb --verbose # list every file scanned
29
+ # ---------------------------------------------------------------------------
30
+
31
+ ROOT = File.expand_path('..', __dir__)
32
+ TAG = /\{%-?\s*(raw|endraw)\s*-?%\}/.freeze
33
+
34
+ # The escape form: a raw block whose entire body is one raw/endraw tag, which
35
+ # is how you render the tag as text. Blanked before scanning so the literal it
36
+ # carries is not mistaken for a real tag.
37
+ ESCAPED = /\{%-?\s*raw\s*-?%\}\{%-?\s*(?:raw|endraw)\s*-?%\}\{%-?\s*endraw\s*-?%\}/.freeze
38
+
39
+ # Directories Jekyll never reads, plus the ones _config.yml excludes. Kept in
40
+ # sync with the `exclude:` list; a path missing here only costs a false
41
+ # positive, never a missed one.
42
+ SKIP_DIRS = %w[
43
+ .git .github .claude .cursor .devcontainer .frontmatter .vscode .obsidian
44
+ .jekyll-cache .sass-cache _site node_modules vendor pkg logs
45
+ docs scripts templates test tests examples submodules gemfiles docker lib
46
+ ].freeze
47
+
48
+ # True when `pos` sits inside a single-backtick code span: an odd number of
49
+ # backtick runs precede it on its own line.
50
+ def in_code_span?(text, pos)
51
+ bol = text.rindex("\n", pos - 1)
52
+ line = text[(bol ? bol + 1 : 0)...pos]
53
+ line.scan(/`+/).size.odd?
54
+ end
55
+
56
+ def scan(path)
57
+ # Blank the escape form (keeping byte offsets and newlines) so the literal
58
+ # tag it renders is not read as a tag itself.
59
+ text = File.read(path, encoding: 'UTF-8')
60
+ .gsub(ESCAPED) { |m| ' ' * m.length }
61
+ problems = []
62
+ in_raw = false
63
+ opened_at = nil
64
+ opened_in_span = false
65
+
66
+ text.to_enum(:scan, TAG).each do
67
+ match = Regexp.last_match
68
+ line = text[0, match.begin(0)].count("\n") + 1
69
+ if in_raw
70
+ # Inside a raw block every tag is literal text — nothing to check.
71
+ if match[1] == 'endraw'
72
+ if opened_in_span && line != opened_at
73
+ problems << "#{path}:#{opened_at}: `{% raw %}` inside a code span " \
74
+ "opens a block that only closes at line #{line} — " \
75
+ 'escape it to show the tag as text'
76
+ end
77
+ in_raw = false
78
+ opened_at = nil
79
+ opened_in_span = false
80
+ end
81
+ next
82
+ end
83
+
84
+ if match[1] == 'raw'
85
+ in_raw = true
86
+ opened_at = line
87
+ # `{% raw %}` inside an inline code span is the documentation-mention
88
+ # trap: it reads as text but opens a real block. Legitimate inline use
89
+ # (`{% raw %}{{ x }}{% endraw %}`) closes on the same line; a mention
90
+ # does not, and swallows everything up to the next `{% endraw %}`.
91
+ opened_in_span = in_code_span?(text, match.begin(0))
92
+ else
93
+ problems << "#{path}:#{line}: `{% endraw %}` with no matching `{% raw %}`"
94
+ end
95
+ end
96
+
97
+ if in_raw
98
+ problems << "#{path}:#{opened_at}: `{% raw %}` is never closed — " \
99
+ 'Liquid will swallow the rest of the file'
100
+ end
101
+ problems
102
+ rescue ArgumentError, Encoding::InvalidByteSequenceError => e
103
+ ["#{path}: could not read as UTF-8 (#{e.class})"]
104
+ end
105
+
106
+ def markdown_files
107
+ Dir.chdir(ROOT) do
108
+ Dir.glob('**/*.{md,markdown}', File::FNM_DOTMATCH).reject do |p|
109
+ p.split(File::SEPARATOR).any? { |seg| SKIP_DIRS.include?(seg) }
110
+ end.sort
111
+ end
112
+ end
113
+
114
+ verbose = ARGV.delete('--verbose')
115
+ targets = ARGV.empty? ? markdown_files : ARGV
116
+
117
+ problems = []
118
+ Dir.chdir(ROOT) do
119
+ targets.each do |path|
120
+ next unless File.file?(path)
121
+
122
+ warn " scanning #{path}" if verbose
123
+ problems.concat(scan(path))
124
+ end
125
+ end
126
+
127
+ if problems.empty?
128
+ puts "✓ lint-liquid-raw: #{targets.size} Markdown files, all " \
129
+ '`{% raw %}` blocks balanced'
130
+ exit 0
131
+ end
132
+
133
+ warn '✗ lint-liquid-raw: unbalanced Liquid raw blocks'
134
+ problems.each { |p| warn " #{p}" }
135
+ warn ''
136
+ warn 'To display a literal tag, escape it: `{% raw %}{% raw %}{% endraw %}`'
137
+ exit 1
@@ -131,7 +131,8 @@ main() {
131
131
  source "$TEST_DIR/test_migrate.sh"
132
132
  source "$TEST_DIR/test_pixelate_images.sh"
133
133
  source "$TEST_DIR/test_content_review.sh"
134
-
134
+ source "$TEST_DIR/test_agent_review_result.sh"
135
+
135
136
  # Summary
136
137
  echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
137
138
  echo -e "${BLUE}Test Summary${NC}"
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ # Bridge for scripts/ci/test_agent_review_result.py (issue #418).
4
+ #
5
+ # The guard that decides whether the Claude content review actually ran lives in
6
+ # scripts/ci/agent_review_result.py, next to the other CI helper
7
+ # (classify_changes.py), and its tests are written in Python beside it. This
8
+ # wrapper is what puts them on the CI path: run_tests.sh sources this file, and
9
+ # ./scripts/bin/test runs run_tests.sh on every PR.
10
+ #
11
+ # scripts/issues/test_verify_close.py is the cautionary example — a real test
12
+ # suite that no runner ever invoked. Do not let this one drift the same way: if
13
+ # the Python tests move, move this line with them.
14
+
15
+ ARR_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
16
+
17
+ print_suite_header "Claude review guard (scripts/ci/agent_review_result.py)"
18
+
19
+ if command -v python3 >/dev/null 2>&1; then
20
+ arr_output="$(python3 "$ARR_ROOT/scripts/ci/test_agent_review_result.py" 2>&1)"
21
+ arr_status=$?
22
+ echo "$arr_output"
23
+ assert_equals "0" "$arr_status" \
24
+ "scripts/ci/test_agent_review_result.py passes (the #418 401-swallow guard)"
25
+ else
26
+ echo "python3 not available — skipping the Claude review guard tests"
27
+ fi