From a4e04cf45ae53304325f93bcd4980b07440baf86 Mon Sep 17 00:00:00 2001 From: patrickryan01 Date: Wed, 2 Dec 2026 20:33:23 -0500 Subject: [PATCH] feat(ci): i put the sales-voice gate in the docs build so every page passes it before it ships --- README.md | 4 + package.json | 4 +- sales-voice-gate/baseline.json | 757 ++++++++++++++++++ sales-voice-gate/vale-gate/.vale.ini | 28 + .../styles/SalesVoice/Believability.yml | 6 + .../vale-gate/styles/SalesVoice/CTAs.yml | 5 + .../vale-gate/styles/SalesVoice/Grade.yml | 6 + .../vale-gate/styles/SalesVoice/Hedges.yml | 10 + .../styles/SalesVoice/HeroLength.yml | 5 + .../vale-gate/styles/SalesVoice/Lawyering.yml | 10 + .../vale-gate/styles/SalesVoice/NodeRed.yml | 5 + .../vale-gate/styles/SalesVoice/OffPage.yml | 8 + .../styles/SalesVoice/PageLength.yml | 5 + .../styles/SalesVoice/RaspberryPi.yml | 5 + .../styles/SalesVoice/SentenceLength.yml | 6 + .../vale-gate/styles/SalesVoice/Standards.yml | 12 + .../vale-gate/styles/SalesVoice/Wording.yml | 12 + scripts/voice-gate.mjs | 116 +++ 18 files changed, 1002 insertions(+), 2 deletions(-) create mode 100644 sales-voice-gate/baseline.json create mode 100644 sales-voice-gate/vale-gate/.vale.ini create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Believability.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/CTAs.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Grade.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Hedges.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/HeroLength.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Lawyering.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/NodeRed.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/OffPage.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/PageLength.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/RaspberryPi.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/SentenceLength.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Standards.yml create mode 100644 sales-voice-gate/vale-gate/styles/SalesVoice/Wording.yml create mode 100644 scripts/voice-gate.mjs diff --git a/README.md b/README.md index d9c141f0..9d00a4f1 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ English plus thirteen languages (es fr it de nb bg el ko ja vi hi zh-hans ar). A A translator who builds pages some other way records them with `node scripts/i18n-source.mjs record [lang ...]` after writing them. It fails when the translation does not have one segment per English segment. +## Sales-voice gate + +`node scripts/voice-gate.mjs dist` runs every English page through the sales-voice rules in `sales-voice-gate/vale-gate` (Vale, pinned in the script and fetched on first run) as the last step of the build. Each rule is a ratchet against `sales-voice-gate/baseline.json`: a page may go down and never up, and a new page starts at zero. After an edit that lowers a count, `node scripts/voice-gate.mjs dist --write-baseline` records the new floor. + ## Writing Every page lands the plane: what the thing is, why it matters, and what it means for the person reading, with the real numbers and the real incident where there is one. The voice is direct and plain: we, never an unnamed I, no profanity, jokes or insults, no positioning against another vendor's product, and no past failure told for its own sake. The reference tables stay exact. Wording a source repo still carries that breaks this is rewritten by the page rules at the end of `scripts/sales-lens-rules.mjs` until the source is fixed. No em dashes as connectors, Oxford commas, American spelling. The house style is in the [brand standard](https://github.com/HotLoop-io/HotLoop-io/blob/main/brand/BRAND.md). diff --git a/package.json b/package.json index 9fde0cac..0e56e12a 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "scripts": { "dev": "astro dev", "sync": "node scripts/sync-docs.mjs", - "build": "node scripts/i18n-check.mjs && node scripts/i18n-source.mjs && node scripts/og.mjs && astro build && node scripts/sitemap-lastmod.mjs dist && node scripts/seo-audit.mjs dist", + "build": "node scripts/i18n-check.mjs && node scripts/i18n-source.mjs && node scripts/og.mjs && astro build && node scripts/sitemap-lastmod.mjs dist && node scripts/seo-audit.mjs dist && node scripts/voice-gate.mjs dist", "preview": "astro preview", - "audit": "node scripts/seo-audit.mjs dist", + "audit": "node scripts/seo-audit.mjs dist && node scripts/voice-gate.mjs dist", "i18n": "node scripts/i18n-check.mjs && node scripts/i18n-source.mjs" }, "dependencies": { diff --git a/sales-voice-gate/baseline.json b/sales-voice-gate/baseline.json new file mode 100644 index 00000000..26556e0f --- /dev/null +++ b/sales-voice-gate/baseline.json @@ -0,0 +1,757 @@ +{ + "business": { + "SentenceLength": 3 + }, + "cascade/ai": { + "Grade": 1, + "SentenceLength": 11 + }, + "cascade/approvals": { + "SentenceLength": 2 + }, + "cascade/building": { + "SentenceLength": 1 + }, + "cascade/connectors": { + "SentenceLength": 16 + }, + "cascade/editor": { + "Grade": 1, + "SentenceLength": 17 + }, + "cascade/file-steps": { + "Grade": 1, + "SentenceLength": 1 + }, + "cascade/git": { + "Grade": 1, + "SentenceLength": 17 + }, + "cascade/governance": { + "SentenceLength": 71 + }, + "cascade/identity": { + "SentenceLength": 44 + }, + "cascade/importing": { + "Grade": 1, + "SentenceLength": 3 + }, + "cascade/mcp": { + "SentenceLength": 18 + }, + "cascade/observability": { + "Grade": 1, + "SentenceLength": 4 + }, + "cascade/overview": { + "SentenceLength": 4 + }, + "cascade/quadlet": { + "Grade": 1, + "SentenceLength": 16 + }, + "cascade/roadmap": { + "SentenceLength": 7 + }, + "cascade/running": { + "SentenceLength": 4 + }, + "cascade/status": { + "SentenceLength": 9 + }, + "codesys/install": { + "SentenceLength": 14 + }, + "codesys/overview": { + "SentenceLength": 9 + }, + "codesys/profile": { + "SentenceLength": 10 + }, + "codesys/roadmap": { + "SentenceLength": 4 + }, + "codesys/where-it-stands": { + "SentenceLength": 5 + }, + "edge-relay/install": { + "Grade": 1, + "SentenceLength": 37 + }, + "edge-relay/overview": { + "Grade": 1, + "SentenceLength": 23 + }, + "edge-relay/reference": { + "Grade": 1, + "SentenceLength": 107 + }, + "edge/edge-publish": { + "Grade": 1, + "SentenceLength": 79 + }, + "edge/install": { + "SentenceLength": 24 + }, + "edge/opc-ua-server": { + "Grade": 1, + "SentenceLength": 131 + }, + "edge/overview": { + "SentenceLength": 11 + }, + "flow/admin-api": { + "Grade": 1, + "SentenceLength": 8 + }, + "flow/back-pressure": { + "Grade": 1, + "SentenceLength": 11 + }, + "flow/benchmarks": { + "SentenceLength": 10 + }, + "flow/building": { + "Grade": 1, + "SentenceLength": 2 + }, + "flow/compatibility": { + "SentenceLength": 3 + }, + "flow/configuration": { + "Grade": 1, + "SentenceLength": 6 + }, + "flow/deploying": { + "SentenceLength": 40 + }, + "flow/deploys": { + "SentenceLength": 62 + }, + "flow/durable-state": { + "SentenceLength": 50 + }, + "flow/editor": { + "SentenceLength": 5 + }, + "flow/failover": { + "Grade": 1, + "SentenceLength": 21 + }, + "flow/flowlab": { + "Grade": 1, + "SentenceLength": 127 + }, + "flow/install": { + "SentenceLength": 36 + }, + "flow/mcp": { + "Grade": 1, + "SentenceLength": 45 + }, + "flow/metrics": { + "Grade": 1, + "SentenceLength": 3 + }, + "flow/migrating-from-node-red": { + "Grade": 1, + "SentenceLength": 31 + }, + "flow/overview": { + "SentenceLength": 10 + }, + "flow/palette": { + "Grade": 1, + "SentenceLength": 18 + }, + "flow/plant-floor": { + "Grade": 1, + "SentenceLength": 55 + }, + "flow/plugins": { + "SentenceLength": 25 + }, + "flow/quick-start": { + "SentenceLength": 4 + }, + "flow/roadmap": { + "SentenceLength": 6 + }, + "flow/sandboxes": { + "Grade": 1, + "SentenceLength": 8 + }, + "flow/security": { + "Grade": 1, + "SentenceLength": 35 + }, + "flow/stations": { + "SentenceLength": 20 + }, + "flow/store-and-forward": { + "Grade": 1, + "SentenceLength": 13 + }, + "flow/subflows": { + "Grade": 1, + "SentenceLength": 4 + }, + "flow/tests": { + "Grade": 1, + "SentenceLength": 48 + }, + "flow/tracing": { + "SentenceLength": 28 + }, + "flow/troubleshooting": { + "Grade": 1, + "SentenceLength": 6 + }, + "flow/typed-wires": { + "SentenceLength": 19 + }, + "flow/where-it-stands": { + "Grade": 1, + "SentenceLength": 7 + }, + "gateway/automations": { + "Grade": 1 + }, + "gateway/blueprints": { + "Grade": 1 + }, + "gateway/fleet": { + "Grade": 1, + "SentenceLength": 34 + }, + "gateway/helpers": { + "Grade": 1 + }, + "gateway/install": { + "SentenceLength": 30 + }, + "gateway/logbook": { + "Grade": 1 + }, + "gateway/mcp": { + "Grade": 1 + }, + "gateway/overview": { + "SentenceLength": 33 + }, + "gateway/protocols": { + "Grade": 1 + }, + "gateway/recipes": { + "Grade": 1 + }, + "gateway/reports": { + "SentenceLength": 38 + }, + "gateway/scripts": { + "Grade": 1 + }, + "gateway/unifi": { + "Grade": 1 + }, + "gateway/upgrading": { + "SentenceLength": 106, + "Lawyering": 1 + }, + "gateway/write-gate": { + "SentenceLength": 31 + }, + "getting-started.html": { + "Grade": 1 + }, + "guides/labview-vi-import": { + "SentenceLength": 16 + }, + "guides/modbus-to-mqtt": { + "SentenceLength": 14 + }, + "guides/node-red-to-flow": { + "SentenceLength": 18 + }, + "guides/opc-ua-to-mqtt": { + "SentenceLength": 7 + }, + "guides/unified-namespace": { + "SentenceLength": 14 + }, + "guides/webvisu-to-hotloop": { + "SentenceLength": 8 + }, + "home": { + "SentenceLength": 5 + }, + "install": { + "SentenceLength": 9 + }, + "install/auto-update": { + "Grade": 1, + "SentenceLength": 30, + "Lawyering": 1 + }, + "install/helm": { + "Grade": 1, + "SentenceLength": 92 + }, + "install/quadlet": { + "Grade": 1, + "SentenceLength": 27 + }, + "iot/api": { + "SentenceLength": 309 + }, + "iot/authentication": { + "Grade": 1, + "SentenceLength": 88 + }, + "iot/automations": { + "SentenceLength": 78 + }, + "iot/backup": { + "Grade": 1, + "SentenceLength": 73, + "Hedges": 1 + }, + "iot/blueprints": { + "SentenceLength": 27 + }, + "iot/broker": { + "Grade": 1, + "SentenceLength": 31 + }, + "iot/codesys-screen-import": { + "Grade": 1, + "SentenceLength": 27 + }, + "iot/dashboards": { + "SentenceLength": 159 + }, + "iot/energy": { + "SentenceLength": 31 + }, + "iot/entities": { + "Grade": 1, + "SentenceLength": 159 + }, + "iot/equipment": { + "Grade": 1, + "SentenceLength": 39 + }, + "iot/helpers": { + "SentenceLength": 34 + }, + "iot/historian-targets": { + "SentenceLength": 52 + }, + "iot/install": { + "SentenceLength": 19 + }, + "iot/integrations": { + "Grade": 1, + "SentenceLength": 40 + }, + "iot/languages": { + "Grade": 1, + "SentenceLength": 9 + }, + "iot/logbook": { + "SentenceLength": 31 + }, + "iot/mcp": { + "SentenceLength": 84 + }, + "iot/migrations": { + "SentenceLength": 11 + }, + "iot/mqtt-discovery": { + "Grade": 1, + "SentenceLength": 117 + }, + "iot/network-discovery": { + "SentenceLength": 22 + }, + "iot/notifications": { + "Grade": 1, + "SentenceLength": 138, + "Lawyering": 2 + }, + "iot/overview": { + "SentenceLength": 8 + }, + "iot/protocols": { + "Grade": 1, + "SentenceLength": 254 + }, + "iot/recipes": { + "SentenceLength": 41 + }, + "iot/screen-file": { + "SentenceLength": 20 + }, + "iot/scripts": { + "SentenceLength": 36 + }, + "iot/sun": { + "SentenceLength": 18, + "Lawyering": 1 + }, + "iot/unifi": { + "SentenceLength": 85 + }, + "iot/weather": { + "SentenceLength": 16 + }, + "licensing": { + "Grade": 1 + }, + "licensing.html": { + "Grade": 1 + }, + "products": { + "SentenceLength": 25 + }, + "releases": { + "SentenceLength": 2 + }, + "releases/cascade-0-1-1": { + "SentenceLength": 7 + }, + "releases/cascade-0-1-2": { + "SentenceLength": 1 + }, + "releases/cascade-1-0-0": { + "Grade": 1, + "SentenceLength": 20 + }, + "releases/cascade-1-0-1": { + "SentenceLength": 3 + }, + "releases/cascade-1-0-2": { + "SentenceLength": 7 + }, + "releases/cascade-1-1-0": { + "SentenceLength": 14 + }, + "releases/cascade-1-1-1": { + "SentenceLength": 3 + }, + "releases/cascade-1-2-0": { + "SentenceLength": 5 + }, + "releases/cascade-1-2-1": { + "SentenceLength": 3 + }, + "releases/cascade-1-3-0": { + "SentenceLength": 13 + }, + "releases/cascade-1-3-1": { + "SentenceLength": 3 + }, + "releases/cascade-1-4-0": { + "SentenceLength": 22 + }, + "releases/cascade-1-4-0-rc-1": { + "SentenceLength": 21 + }, + "releases/cascade-1-4-1": { + "SentenceLength": 5 + }, + "releases/cascade-1-4-2": { + "SentenceLength": 5 + }, + "releases/cascade-1-5-0": { + "SentenceLength": 7 + }, + "releases/cascade-1-5-1": { + "SentenceLength": 2 + }, + "releases/cascade-1-6-0": { + "SentenceLength": 16 + }, + "releases/cascade-1-6-1": { + "SentenceLength": 1 + }, + "releases/codesys-0-3-0": { + "SentenceLength": 6 + }, + "releases/codesys-0-3-1": { + "SentenceLength": 4 + }, + "releases/codesys-0-3-10": { + "SentenceLength": 5 + }, + "releases/codesys-0-3-2": { + "SentenceLength": 3 + }, + "releases/codesys-0-3-3": { + "SentenceLength": 3 + }, + "releases/codesys-0-3-4": { + "SentenceLength": 2 + }, + "releases/codesys-0-3-5": { + "SentenceLength": 3 + }, + "releases/codesys-0-3-7": { + "Grade": 1, + "SentenceLength": 2 + }, + "releases/codesys-0-3-8": { + "SentenceLength": 2 + }, + "releases/core": { + "SentenceLength": 2 + }, + "releases/flow-2-1-0": { + "SentenceLength": 17 + }, + "releases/flow-2-10-0": { + "SentenceLength": 19 + }, + "releases/flow-2-10-1": { + "SentenceLength": 2 + }, + "releases/flow-2-10-2": { + "SentenceLength": 1 + }, + "releases/flow-2-11-0": { + "SentenceLength": 18 + }, + "releases/flow-2-11-1": { + "SentenceLength": 3 + }, + "releases/flow-2-12-0": { + "SentenceLength": 28 + }, + "releases/flow-2-12-1": { + "SentenceLength": 2 + }, + "releases/flow-2-13-0": { + "Grade": 1, + "SentenceLength": 22 + }, + "releases/flow-2-13-1": { + "SentenceLength": 2 + }, + "releases/flow-2-14-0": { + "SentenceLength": 12 + }, + "releases/flow-2-14-1": { + "SentenceLength": 2 + }, + "releases/flow-2-15-0": { + "SentenceLength": 16 + }, + "releases/flow-2-15-1": { + "SentenceLength": 2 + }, + "releases/flow-2-16-0": { + "Grade": 1, + "SentenceLength": 22 + }, + "releases/flow-2-16-1": { + "SentenceLength": 3 + }, + "releases/flow-2-16-2": { + "SentenceLength": 8 + }, + "releases/flow-2-16-3": { + "SentenceLength": 9 + }, + "releases/flow-2-16-4": { + "SentenceLength": 9 + }, + "releases/flow-2-16-5": { + "SentenceLength": 8 + }, + "releases/flow-2-16-6": { + "SentenceLength": 9 + }, + "releases/flow-2-16-7": { + "SentenceLength": 6 + }, + "releases/flow-2-16-8": { + "SentenceLength": 8 + }, + "releases/flow-2-17-1": { + "SentenceLength": 18 + }, + "releases/flow-2-17-2": { + "SentenceLength": 3 + }, + "releases/flow-2-18-0": { + "SentenceLength": 6 + }, + "releases/flow-2-2-0": { + "SentenceLength": 18 + }, + "releases/flow-2-3-0": { + "SentenceLength": 39 + }, + "releases/flow-2-4-0": { + "SentenceLength": 9 + }, + "releases/flow-2-5-0": { + "SentenceLength": 14 + }, + "releases/flow-2-6-0": { + "SentenceLength": 5 + }, + "releases/flow-2-7-0": { + "SentenceLength": 19 + }, + "releases/flow-2-7-1": { + "SentenceLength": 3 + }, + "releases/flow-2-8-0": { + "SentenceLength": 11 + }, + "releases/flow-2-8-1": { + "SentenceLength": 3 + }, + "releases/flow-2-9-0": { + "SentenceLength": 13 + }, + "releases/flow-2-9-1": { + "SentenceLength": 6 + }, + "releases/hotloop-4-16-0": { + "Grade": 1, + "SentenceLength": 9 + }, + "releases/hotloop-4-17-0": { + "Grade": 1, + "SentenceLength": 11 + }, + "releases/hotloop-4-18-10": { + "SentenceLength": 25 + }, + "releases/hotloop-4-18-11": { + "SentenceLength": 67, + "Lawyering": 1 + }, + "releases/hotloop-4-18-3": { + "Grade": 1 + }, + "releases/hotloop-4-19-10": { + "SentenceLength": 2 + }, + "releases/hotloop-4-19-11": { + "SentenceLength": 20 + }, + "releases/hotloop-4-19-4": { + "SentenceLength": 58 + }, + "releases/hotloop-4-19-5": { + "SentenceLength": 3 + }, + "releases/hotloop-4-19-8": { + "Grade": 1, + "SentenceLength": 35 + }, + "releases/hotloop-4-20-0": { + "SentenceLength": 13 + }, + "releases/hotloop-4-20-1": { + "SentenceLength": 3 + }, + "releases/hotloop-4-20-2": { + "Grade": 1, + "SentenceLength": 10 + }, + "releases/hotloop-4-21-0": { + "Grade": 1, + "SentenceLength": 10 + }, + "releases/hotloop-4-21-1": { + "SentenceLength": 4 + }, + "releases/hotloop-4-22-0": { + "SentenceLength": 5 + }, + "releases/hotloop-4-22-1": { + "SentenceLength": 3 + }, + "releases/hotloop-4-23-1": { + "SentenceLength": 8 + }, + "releases/hotloop-4-23-2": { + "SentenceLength": 16 + }, + "releases/hotloop-4-23-3": { + "SentenceLength": 3 + }, + "releases/hotloop-4-23-4": { + "SentenceLength": 6 + }, + "releases/hotloop-4-23-5": { + "SentenceLength": 8 + }, + "releases/hotloop-4-23-6": { + "Grade": 1, + "SentenceLength": 25 + }, + "releases/hotloop-4-24-0": { + "SentenceLength": 6 + }, + "releases/hotloop-4-24-2": { + "SentenceLength": 9 + }, + "releases/hotloop-4-24-3": { + "Grade": 1, + "SentenceLength": 4 + }, + "releases/hotloop-4-24-4": { + "SentenceLength": 3 + }, + "releases/transmitter-1-0-0": { + "Grade": 1, + "SentenceLength": 17 + }, + "releases/transmitter-1-1-0": { + "SentenceLength": 14 + }, + "releases/transmitter-1-2-0": { + "Grade": 1, + "SentenceLength": 15 + }, + "releases/transmitter-1-3-0": { + "SentenceLength": 13 + }, + "roadmap": { + "SentenceLength": 9 + }, + "transmitter/api": { + "SentenceLength": 2 + }, + "transmitter/embernet": { + "SentenceLength": 1 + }, + "transmitter/install": { + "Grade": 1, + "SentenceLength": 6 + }, + "transmitter/overview": { + "SentenceLength": 7 + }, + "transmitter/proof": { + "Grade": 1, + "SentenceLength": 10 + }, + "transmitter/roadmap": { + "Grade": 1, + "SentenceLength": 8 + }, + "transmitter/timing": { + "SentenceLength": 6 + }, + "transmitter/wire-format": { + "Grade": 1, + "SentenceLength": 22 + } +} diff --git a/sales-voice-gate/vale-gate/.vale.ini b/sales-voice-gate/vale-gate/.vale.ini new file mode 100644 index 00000000..9873de95 --- /dev/null +++ b/sales-voice-gate/vale-gate/.vale.ini @@ -0,0 +1,28 @@ +# Fireball sales-voice gate. Run: vale --config .vale.ini +# Name copy files __.md, for example embernet.ai__pricing.page.md or hotloop.io__flow.hero.md. +# The hero block is *.hero.md and a full landing page is *.page.md. +# Node-RED is checked on embernet.ai copy; Raspberry Pi on hotloop.io copy (not release notes). +StylesPath = styles +MinAlertLevel = suggestion + +[*.md] +BasedOnStyles = SalesVoice +SalesVoice.HeroLength = NO +SalesVoice.PageLength = NO +SalesVoice.NodeRed = NO +SalesVoice.RaspberryPi = NO + +[*.hero.md] +SalesVoice.HeroLength = YES + +[*.page.md] +SalesVoice.PageLength = YES + +[{embernet.ai*.md,**/embernet.ai*.md}] +SalesVoice.NodeRed = YES + +[{hotloop.io*.md,**/hotloop.io*.md}] +SalesVoice.RaspberryPi = YES + +[{hotloop.io__releases*.md,**/hotloop.io__releases*.md}] +SalesVoice.RaspberryPi = NO diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/Believability.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/Believability.yml new file mode 100644 index 00000000..9aaff035 --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/Believability.yml @@ -0,0 +1,6 @@ +extends: existence +message: "'%s' is a speed or scale claim buyers argue with. Sell the outcome or use real numbers (40+ nodes in under 5 days)." +level: error +ignorecase: true +tokens: + - thousands of nodes diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/CTAs.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/CTAs.yml new file mode 100644 index 00000000..46b0038e --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/CTAs.yml @@ -0,0 +1,5 @@ +extends: existence +message: "'%s' is a dead CTA. Name the outcome as verb plus object (Start the free Pilot, Talk to an engineer)." +level: error +raw: + - '(? 40.0" diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/Lawyering.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/Lawyering.yml new file mode 100644 index 00000000..eeaff3ee --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/Lawyering.yml @@ -0,0 +1,10 @@ +extends: existence +message: "'%s' reads as a caveat or filler. Write it as a positive decision or cut it." +level: error +ignorecase: true +tokens: + - fine print + - disclaimer + - caveat + - n/m + - not certified diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/NodeRed.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/NodeRed.yml new file mode 100644 index 00000000..c32e52bc --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/NodeRed.yml @@ -0,0 +1,5 @@ +extends: existence +message: "'%s' stays off EmberNet pages. The EmberNet side runs HotLoop for logic." +level: error +raw: + - '(? 725.0 || words < 250.0" diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/RaspberryPi.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/RaspberryPi.yml new file mode 100644 index 00000000..8838daae --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/RaspberryPi.yml @@ -0,0 +1,5 @@ +extends: existence +message: "Don't name '%s' in HotLoop copy. Say it runs on any low-cost box next to a machine." +level: error +tokens: + - Raspberry Pi diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/SentenceLength.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/SentenceLength.yml new file mode 100644 index 00000000..4404987f --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/SentenceLength.yml @@ -0,0 +1,6 @@ +extends: metric +message: "Sentence has %s words. Keep every sentence to 20 words or fewer." +level: error +scope: sentence +formula: words +condition: "> 20.0" diff --git a/sales-voice-gate/vale-gate/styles/SalesVoice/Standards.yml b/sales-voice-gate/vale-gate/styles/SalesVoice/Standards.yml new file mode 100644 index 00000000..3adbc53c --- /dev/null +++ b/sales-voice-gate/vale-gate/styles/SalesVoice/Standards.yml @@ -0,0 +1,12 @@ +extends: existence +message: "'%s' is a weasel word on a standard. List the standard by name and stop." +level: error +nonword: true +tokens: + - '(? !a.startsWith('--')) || 'dist'); +const VALE = { version: '3.27.0', sha256: 'c80d62f6bce87b81843ac5b512a26e63213927b957adba0a64fc594570da2000' }; +const INFO = new Set(['SalesVoice.HeroLength', 'SalesVoice.PageLength']); +const SKIP = new Set(['404', 'license', 'terms', 'es', 'fr', 'it', 'de', 'nb', 'bg', 'el', 'ko', 'ja', 'vi', 'hi', 'zh-hans', 'ar']); + +async function vale() { + if (process.env.VALE) return process.env.VALE; + const onPath = spawnSync('vale', ['--version'], { encoding: 'utf8' }); + if (onPath.status === 0 && onPath.stdout.includes(VALE.version)) return 'vale'; + const dir = join(ROOT, 'node_modules/.cache/vale', VALE.version); + const bin = join(dir, 'vale'); + if (existsSync(bin)) return bin; + mkdirSync(dir, { recursive: true }); + const url = `https://github.com/vale-cli/vale/releases/download/v${VALE.version}/vale_${VALE.version}_Linux_64-bit.tar.gz`; + const r = await fetch(url); + if (!r.ok) throw new Error(`voice-gate: could not fetch Vale ${VALE.version}: HTTP ${r.status}`); + const buf = Buffer.from(await r.arrayBuffer()); + const sum = createHash('sha256').update(buf).digest('hex'); + if (sum !== VALE.sha256) throw new Error(`voice-gate: Vale tarball sha256 ${sum} is not the pinned ${VALE.sha256}`); + writeFileSync(join(dir, 'vale.tgz'), buf); + const t = spawnSync('tar', ['xzf', join(dir, 'vale.tgz'), '-C', dir, 'vale'], { encoding: 'utf8' }); + if (t.status !== 0) throw new Error('voice-gate: could not unpack Vale: ' + t.stderr); + chmodSync(bin, 0o755); + return bin; +} + +const walk = (d, o = []) => { for (const e of readdirSync(d)) { const p = join(d, e); statSync(p).isDirectory() ? walk(p, o) : o.push(p); } return o; }; + +// One markdown file per page, named for its site so the site rules apply (docs.hotloop.io__.page.md). +const work = join(ROOT, 'node_modules/.cache/voice-gate-copy'); +rmSync(work, { recursive: true, force: true }); +mkdirSync(work, { recursive: true }); +const pages = new Map(); +for (const f of walk(dist).filter((f) => f.endsWith('index.html'))) { + const rel = relative(dist, dirname(f)); + const route = rel === '' ? 'home' : rel; + if (SKIP.has(route.split(sep)[0])) continue; + const root = parse(readFileSync(f, 'utf8')); + const main = root.querySelector('main .sl-markdown-content, main') || root; + main.querySelectorAll('script,style,svg,nav,footer,header').forEach((e) => e.remove()); + const lines = []; + for (const el of main.querySelectorAll('h1,h2,h3,p,li,button,a')) { + if (el.tagName !== 'A' && el.querySelector('a') && el.tagName === 'LI') continue; + const text = el.text.replace(/\s+/g, ' ').trim(); + if (!text) continue; + lines.push((el.tagName === 'H1' ? '# ' : /^H[23]$/.test(el.tagName) ? '## ' : '') + text + '\n'); + } + const name = `docs.hotloop.io__${route.split(sep).join('-')}.page.md`; + writeFileSync(join(work, name), lines.join('\n')); + pages.set(name, route); +} + +const bin = await vale(); +const cfg = join(ROOT, 'sales-voice-gate/vale-gate/.vale.ini'); +const run = spawnSync(bin, ['--config', cfg, '--output=JSON', work], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 }); +if (!run.stdout || (run.status !== 0 && run.status !== 1)) { + console.error('voice-gate: Vale did not run: ' + (run.stderr || run.error || run.status)); + process.exit(2); +} +const result = JSON.parse(run.stdout); + +const counts = {}; +const info = {}; +for (const [file, alerts] of Object.entries(result)) { + const route = pages.get(file.split(sep).pop()); + for (const a of alerts) { + if (INFO.has(a.Check)) info[a.Check] = (info[a.Check] || 0) + 1; + else { const k = a.Check.split('.')[1]; ((counts[route] ??= {})[k] = (counts[route][k] || 0) + 1); } + } +} + +const baseFile = join(ROOT, 'sales-voice-gate/baseline.json'); +if (writeBase) { + const sorted = Object.fromEntries(Object.entries(counts).sort(([a], [b]) => a.localeCompare(b))); + writeFileSync(baseFile, JSON.stringify(sorted, null, 2) + '\n'); + console.log(`voice-gate: baseline written for ${Object.keys(sorted).length} pages`); +} +const base = existsSync(baseFile) ? JSON.parse(readFileSync(baseFile, 'utf8')) : {}; +const worse = []; +let improved = 0; +for (const route of pages.values()) { + const now = counts[route] || {}; + const was = base[route] || {}; + for (const k of new Set([...Object.keys(now), ...Object.keys(was)])) { + if ((now[k] || 0) > (was[k] || 0)) worse.push(`${route}: ${k} ${was[k] || 0} -> ${now[k]}`); + else if ((now[k] || 0) < (was[k] || 0)) improved++; + } +} +if (worse.length && !writeBase) { + console.error(`voice-gate: ${worse.length} problem(s) in the copy:`); + for (const w of worse) console.error(' FAIL ' + w); + process.exit(1); +} +console.log(`voice-gate: ${pages.size} English pages at or under the baseline (${improved} count(s) below it; page-length notes ${info['SalesVoice.PageLength'] || 0}, hero-length notes ${info['SalesVoice.HeroLength'] || 0})`);