@heyramzi/lint 2.2.0 → 2.3.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/bin/heyramzi-jev-code.js +3 -3
- package/bin/heyramzi-slop.js +2 -2
- package/data/slop/patterns/comma-clauses.js +13 -0
- package/jev-code.js +1 -1
- package/jev.js +21 -12
- package/package.json +2 -2
- package/scripts/jev-bench.mjs +3 -3
- package/scripts/jev-code-bench.mjs +3 -3
- package/slop.js +49 -20
package/bin/heyramzi-jev-code.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
|
-
import { NO_KEY,
|
|
10
|
+
import { NO_KEY, gatewayKey } from "#lint/jev.js";
|
|
11
11
|
import { RULES, auditCode } from "#lint/jev-code.js";
|
|
12
12
|
|
|
13
13
|
// =========================
|
|
@@ -62,7 +62,7 @@ async function hook() {
|
|
|
62
62
|
const file = input.tool_input?.file_path ?? "";
|
|
63
63
|
if (!file.startsWith(`${STUDIO}/`) || SKIP.test(file)) return 0;
|
|
64
64
|
const code = writtenText(input.tool_input).slice(0, MAX_CHARS);
|
|
65
|
-
const k =
|
|
65
|
+
const k = gatewayKey();
|
|
66
66
|
if (!code || !k) return 0;
|
|
67
67
|
|
|
68
68
|
const timeout = new Promise((resolve) => setTimeout(() => resolve(null), TIMEOUT_MS).unref());
|
|
@@ -84,7 +84,7 @@ async function hook() {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async function files(paths) {
|
|
87
|
-
const k =
|
|
87
|
+
const k = gatewayKey();
|
|
88
88
|
if (!k) {
|
|
89
89
|
process.stderr.write(`heyramzi-jev-code ${NO_KEY}\n`);
|
|
90
90
|
return 2;
|
package/bin/heyramzi-slop.js
CHANGED
|
@@ -56,7 +56,7 @@ import { join } from "node:path";
|
|
|
56
56
|
import { shapes } from "#lint/data/slop-words.js";
|
|
57
57
|
import { patterns } from "#lint/data/slop/patterns.js";
|
|
58
58
|
import { titleTells } from "#lint/data/slop/title-tells.js";
|
|
59
|
-
import { REVIEW, auditShapes, isUnavailable,
|
|
59
|
+
import { REVIEW, auditShapes, isUnavailable, gatewayKey, proseOf } from "#lint/jev.js";
|
|
60
60
|
import { slopGate } from "#lint/slop.js";
|
|
61
61
|
|
|
62
62
|
// =========================
|
|
@@ -147,7 +147,7 @@ function gateBoard(raw, register) {
|
|
|
147
147
|
/** The model-scored shapes of one file, or null after noting why the model could not answer. */
|
|
148
148
|
async function modelShapes(file, raw) {
|
|
149
149
|
try {
|
|
150
|
-
jevKey ??=
|
|
150
|
+
jevKey ??= gatewayKey();
|
|
151
151
|
const text = /\.(html?|svelte|vue)$/i.test(file) ? proseOf(raw) : raw;
|
|
152
152
|
return await auditShapes(text, { key: jevKey, block: shapeBlock });
|
|
153
153
|
} catch (err) {
|
|
@@ -54,6 +54,19 @@ export const patternsCommaClauses = [
|
|
|
54
54
|
rule: 'A name, a comma, then a stock tail with no verb ("end to end", "in one place"), or a mirrored "one X, one Y". It reads as a slogan and says nothing a sentence would not. Ramzi, 28 Sep 2026, on "Editor OS, end to end". Write the sentence, or cut to the name.',
|
|
55
55
|
example: '"Editor OS, end to end" / "one camera, one go" / "No setup, no code"',
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
id: "comma-hung-tag",
|
|
59
|
+
// Per LINE: a name of 1 to 4 words, a comma, then a tail with no verb: a preposition and one noun, "by design", or "made"/"done" plus a word.
|
|
60
|
+
|
|
61
|
+
// Open where `comma-hung-phrase` is a closed list, because the list missed "CBAM, in context." on the CBAM news page, 27 Oct 2026.
|
|
62
|
+
|
|
63
|
+
// A sort label ("Checks, in order", "Codes, by sector"), a state ("in review") and a unit ("Price, in EUR", "Cement, in tonnes") stay out.
|
|
64
|
+
test: /^[ \t]*(?:#{1,6}[ \t]+|[-*+][ \t]+|[\w$]+:[ \t]*["'`])?[A-Z][A-Za-zà-ÿ'’-]*(?:[ \t]+[A-Za-zà-ÿ'’-]+){0,3}(?<!\b(?:in|on|at|up|out|off)),[ \t]+(?:in[ \t]+plain[ \t]+[A-Za-zà-ÿ]+|(?:in|at|on)[ \t]+(?:(?:a|an|the|one|real)[ \t]+)?(?!(?:z-)?order\b|(?:review|progress|stock|draft|tonnes?|tons?|kg|grams?|euros?|dollars?|days?|hours?|minutes?|seconds?|weeks?|months?|years?|percent|units?|words?|pages?|total)\b)[a-zà-ÿ][a-zà-ÿ-]*|by[ \t]+(?:design|default)|(?:made|done)[ \t]+[a-zà-ÿ]+)[ \t]*[.!]?(?:["'`][,;]?)?[ \t]*$/m,
|
|
65
|
+
name: "Comma-hung tag",
|
|
66
|
+
rule: 'A short name, a comma, and a verbless tail that sounds like a tagline: "in context", "made simple", "on demand". The tail promises a quality and never says what the page holds. Ramzi, 27 Oct 2026, on the CBAM news heading "CBAM, in context.". Write what the page gives the reader, or cut to the name.',
|
|
67
|
+
example:
|
|
68
|
+
'"CBAM, in context." / "Pricing, made simple." / "Your data, on demand" / "Compliance, by design"',
|
|
69
|
+
},
|
|
57
70
|
{
|
|
58
71
|
id: "guided-tour-promise",
|
|
59
72
|
// A relative clause restating a thing's obvious job as hand-holding.
|
package/jev-code.js
CHANGED
|
@@ -179,7 +179,7 @@ export function chunks(code) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/** Every chunk of `code` against the rules for `file`, split into `findings` and `review`. */
|
|
182
|
-
export async function auditCode(code, file, { key = process.env.
|
|
182
|
+
export async function auditCode(code, file, { key = process.env.AI_GATEWAY_API_KEY } = {}) {
|
|
183
183
|
if (!key) throw new Error(`jev-code ${NO_KEY}`);
|
|
184
184
|
const rules = rulesFor(file);
|
|
185
185
|
const items = chunks(code).map((c) => ({ code: `// ${file.split("/").pop()}\n${c}` }));
|
package/jev.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The judgement half of the humanizer patterns, asked of TypeSafe Jev per sentence
|
|
3
|
-
* and per paragraph, through the
|
|
3
|
+
* and per paragraph, through the Vercel AI Gateway. Bench: scripts/jev-bench.mjs. Why these shapes: TECHLOG.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
@@ -12,13 +12,13 @@ import { join } from "node:path";
|
|
|
12
12
|
// =========================
|
|
13
13
|
// CONSTANTS
|
|
14
14
|
// =========================
|
|
15
|
-
/** TypeSafe's /v1/systemone behind
|
|
16
|
-
const
|
|
15
|
+
/** TypeSafe's /v1/systemone behind the Vercel AI Gateway, which bills the gateway credits. Same body and answers. */
|
|
16
|
+
const GATEWAY_URL = "https://ai-gateway.vercel.sh/typesafe/v1/systemone";
|
|
17
17
|
/** One request that hangs must not hang a draft: past this it counts as unreachable. */
|
|
18
18
|
const TIMEOUT_MS = 30_000;
|
|
19
|
-
/**
|
|
20
|
-
export const MODEL = "typesafe/jev-1.13";
|
|
21
|
-
export const NO_KEY = "needs
|
|
19
|
+
/** Pinned to the version the thresholds were benched on; the gateway also serves `typesafe-ai/jev` (latest). */
|
|
20
|
+
export const MODEL = "typesafe-ai/jev-1.13.0";
|
|
21
|
+
export const NO_KEY = "needs AI_GATEWAY_API_KEY (Proton Pass, Dev vault, item Vercel AI Gateway)";
|
|
22
22
|
export const FAIL = 0.75;
|
|
23
23
|
export const REVIEW = 0.6;
|
|
24
24
|
/** Scores drift about 0.05 between identical calls, so each item is asked RUNS times and its worst score counts. */
|
|
@@ -160,13 +160,19 @@ export function paragraphs(text) {
|
|
|
160
160
|
.map((paragraph) => ({ paragraph }));
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
/** `
|
|
164
|
-
export function
|
|
165
|
-
if (process.env.
|
|
163
|
+
/** `AI_GATEWAY_API_KEY` from the env, else Proton Pass (Dev vault, item Vercel AI Gateway), else "". */
|
|
164
|
+
export function gatewayKey() {
|
|
165
|
+
if (process.env.AI_GATEWAY_API_KEY) return process.env.AI_GATEWAY_API_KEY;
|
|
166
166
|
try {
|
|
167
167
|
return execFileSync(
|
|
168
168
|
"pass-cli",
|
|
169
|
-
[
|
|
169
|
+
[
|
|
170
|
+
"item",
|
|
171
|
+
"view",
|
|
172
|
+
"--vault-name=Dev",
|
|
173
|
+
"--item-title=Vercel AI Gateway",
|
|
174
|
+
"--field=AI_GATEWAY_API_KEY",
|
|
175
|
+
],
|
|
170
176
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 30_000 },
|
|
171
177
|
).trim();
|
|
172
178
|
} catch {
|
|
@@ -182,7 +188,7 @@ function unavailable(message) {
|
|
|
182
188
|
export const isUnavailable = (err) => err instanceof Error && err.name === "JevUnavailable";
|
|
183
189
|
|
|
184
190
|
/** The URL is overridable so a test can point it at a local server or an unresolvable host. */
|
|
185
|
-
const endpoint = () => process.env.HEYRAMZI_JEV_URL ||
|
|
191
|
+
const endpoint = () => process.env.HEYRAMZI_JEV_URL || GATEWAY_URL;
|
|
186
192
|
|
|
187
193
|
function why(err) {
|
|
188
194
|
if (err?.name === "TimeoutError") return `timed out after ${TIMEOUT_MS / 1000}s`;
|
|
@@ -333,7 +339,10 @@ export async function judge(items, shapes, field, key, block = FAIL) {
|
|
|
333
339
|
* Shapes Jev reads in a text. A report (`review`) unless `block` names a bar; a hit at or above it
|
|
334
340
|
* is a `finding`. Throws JevUnavailable when the model can't answer.
|
|
335
341
|
*/
|
|
336
|
-
export async function auditShapes(
|
|
342
|
+
export async function auditShapes(
|
|
343
|
+
text,
|
|
344
|
+
{ key = process.env.AI_GATEWAY_API_KEY, block = Infinity } = {},
|
|
345
|
+
) {
|
|
337
346
|
if (!key) throw unavailable(`--jev ${NO_KEY}`);
|
|
338
347
|
const a = await judge(sentences(text), SHAPES, "sentence", key, block);
|
|
339
348
|
const b = await judge(paragraphs(text), PARAGRAPH_SHAPES, "paragraph", key, block);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyramzi/lint",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Shared oxlint rules, base config and gates for Studio projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@heyramzi/social": "^1.2.
|
|
83
|
+
"@heyramzi/social": "^1.2.1"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"voice:refresh": "node scripts/harvest-voice.mjs --write",
|
package/scripts/jev-bench.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Scores every held-out line against every Jev shape. Exits 1 when a bad line fails nothing or a plain line fails something. Run after any change to SHAPES: `node scripts/jev-bench.mjs`.
|
|
3
3
|
|
|
4
|
-
// Needs
|
|
4
|
+
// Needs AI_GATEWAY_API_KEY, from the env or Proton Pass (Dev vault, item Vercel AI Gateway).
|
|
5
5
|
|
|
6
6
|
import { PARAGRAPHS, SENTENCES } from "#lint/data/jev-bench.js";
|
|
7
|
-
import { PARAGRAPH_SHAPES, SHAPES, auditShapes,
|
|
7
|
+
import { PARAGRAPH_SHAPES, SHAPES, auditShapes, gatewayKey } from "#lint/jev.js";
|
|
8
8
|
|
|
9
9
|
// Measuring the model, so no cached score stands in for a fresh answer.
|
|
10
10
|
process.env.HEYRAMZI_SLOP_CACHE = "off";
|
|
11
11
|
|
|
12
12
|
const FAIL = 0.75;
|
|
13
13
|
let wrong = 0;
|
|
14
|
-
const key =
|
|
14
|
+
const key = gatewayKey();
|
|
15
15
|
|
|
16
16
|
async function score(rows, shapes, wrap) {
|
|
17
17
|
for (const row of rows) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Scores the Jev code rules on the synthetic set, per tier. Exits 1 when HELDOUT misses its bar.
|
|
3
|
-
// `node scripts/jev-code-bench.mjs [train|heldout|all]`. Needs
|
|
3
|
+
// `node scripts/jev-code-bench.mjs [train|heldout|all]`. Needs AI_GATEWAY_API_KEY (env or Proton Pass). Why: TECHLOG.md.
|
|
4
4
|
|
|
5
5
|
import { HELDOUT, TRAIN } from "#lint/data/jev-code-bench.js";
|
|
6
6
|
import { auditCode } from "#lint/jev-code.js";
|
|
7
|
-
import {
|
|
7
|
+
import { gatewayKey } from "#lint/jev.js";
|
|
8
8
|
|
|
9
9
|
const set = process.argv[2] ?? "all";
|
|
10
|
-
const key =
|
|
10
|
+
const key = gatewayKey();
|
|
11
11
|
|
|
12
12
|
async function score(name, cases) {
|
|
13
13
|
const tally = { bad: 0, high: 0, medium: 0, plain: 0, fpHigh: 0, fpMedium: 0 };
|
package/slop.js
CHANGED
|
@@ -85,26 +85,55 @@ const bounded = (word) =>
|
|
|
85
85
|
* Entities go before tags. A preheader is deliberately padded with zero-width entities, and decoding those first would turn the padding into real characters and make every length count downstream wrong.
|
|
86
86
|
*/
|
|
87
87
|
export function stripMarkup(raw) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
88
|
+
const text = raw
|
|
89
|
+
.replace(/<(script|style)[\s\S]*?<\/\1>/gi, " ")
|
|
90
|
+
// A markup comment is a note to the next developer, not copy.
|
|
91
|
+
|
|
92
|
+
// It goes with the script block, for the same reason: the CBAM pages rule their sections with `<!-- name -->` wrapped in rows of em dashes, which reported 8 dashes nobody reads.
|
|
93
|
+
.replace(/<!--[\s\S]*?-->/g, " ")
|
|
94
|
+
.replace(/&[a-z]+;|&#\d+;/gi, " ")
|
|
95
|
+
.replace(/<[^>]+>/g, " ");
|
|
96
|
+
// Svelte and Vue control blocks are code that survives tag stripping, and their loop variables read as prose: `{#each items as row,
|
|
97
|
+
|
|
98
|
+
// i (row)}` counted `i` as a first-person pronoun and failed 3 pages on the pronoun ledger.
|
|
99
|
+
|
|
100
|
+
// Only `{#`, `{:`, `{/` and `{@` go; a plain `{value}` interpolation is left alone, because the copy it stands for is audited where it is written.
|
|
101
|
+
return withoutTemplateTags(text)
|
|
102
|
+
.replace(/[ \t]+/g, " ")
|
|
103
|
+
.trim();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Drops every `{#`, `{:`, `{/` and `{@` block up to its balancing brace, skipping braces inside quotes.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* A `[^}]*` regex stopped at the first nested brace, so a JSON-LD object inside `{@html}` read as copy and failed `comma-run` on a CBAM news page, 27 Oct 2026.
|
|
112
|
+
*/
|
|
113
|
+
export function withoutTemplateTags(text) {
|
|
114
|
+
let out = "";
|
|
115
|
+
let i = 0;
|
|
116
|
+
while (i < text.length) {
|
|
117
|
+
if (text[i] !== "{" || !"#:/@".includes(text[i + 1] ?? "")) {
|
|
118
|
+
out += text[i++];
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
let depth = 0;
|
|
122
|
+
let quote = "";
|
|
123
|
+
let j = i;
|
|
124
|
+
for (; j < text.length; j++) {
|
|
125
|
+
const c = text[j];
|
|
126
|
+
if (quote) {
|
|
127
|
+
if (c === "\\") j++;
|
|
128
|
+
else if (c === quote) quote = "";
|
|
129
|
+
} else if (c === '"' || c === "'" || c === "`") quote = c;
|
|
130
|
+
else if (c === "{") depth++;
|
|
131
|
+
else if (c === "}" && --depth === 0) break;
|
|
132
|
+
}
|
|
133
|
+
out += " ";
|
|
134
|
+
i = j + 1;
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
108
137
|
}
|
|
109
138
|
|
|
110
139
|
const isPictographic = (ch) => /\p{Extended_Pictographic}/u.test(ch);
|