@heyramzi/lint 2.4.4 → 2.6.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 +54 -2
- package/bin/heyramzi-jev-code.js +4 -55
- package/bin/heyramzi-repo-rules.js +20 -1
- package/bin/heyramzi-slop.js +24 -8
- package/data/jev-bench.js +8 -0
- package/data/slop/patterns/numbers-and-runs.js +1 -1
- package/data/slop/shapes-framing.js +7 -0
- package/file-tokens.js +1 -1
- package/inline-path.js +1 -1
- package/jev-code.js +2 -1
- package/jev-core.d.ts +93 -0
- package/jev-core.js +344 -0
- package/jev.js +66 -285
- package/package.json +8 -1
- package/register.d.ts +18 -1
- package/register.js +83 -8
- package/repo-rules/imports.js +88 -0
- package/repo-rules/packages.js +19 -5
- package/repo-rules/tree.js +23 -4
- package/repo-rules/workflows.js +37 -2
- package/repo-rules.js +2 -0
- package/scripts/jev-bench.mjs +2 -1
- package/scripts/reddit-bench-harvest.mjs +294 -0
- package/scripts/reddit-bench.mjs +114 -0
- package/slop.js +4 -2
package/README.md
CHANGED
|
@@ -291,8 +291,9 @@ the banned words in pieces, so it passes its own gate.
|
|
|
291
291
|
failure says what to do instead. It reads the staged blob, so it judges what the commit records.
|
|
292
292
|
|
|
293
293
|
- **Package manager:** a staged `package-lock.json`, `yarn.lock`, `bun.lock` or `bun.lockb` fails.
|
|
294
|
-
- **@heyramzi dependencies:** a `link:`, `file:` or path spec fails, and so does
|
|
295
|
-
entry with an `integrity` and no `tarball` URL.
|
|
294
|
+
- **@heyramzi dependencies:** a `link:`, `file:` or path spec the commit adds fails, and so does
|
|
295
|
+
any lockfile entry with an `integrity` and no `tarball` URL. One HEAD already holds doesn't
|
|
296
|
+
block an edit to the rest of that manifest; `--all` still reports every one.
|
|
296
297
|
- **Import maps:** a published `@heyramzi/*` package with `#src` imports maps `"#src/*.js"` to
|
|
297
298
|
`./src/*.ts` when it ships src, or `"#src/*"` to `{ types, default }` when it ships dist.
|
|
298
299
|
- **Credentials:** an `_authToken` line in a committed `.npmrc`, and the dead
|
|
@@ -304,11 +305,62 @@ failure says what to do instead. It reads the staged blob, so it judges what the
|
|
|
304
305
|
scripts, the `fallow` reference in `vibekit.json`, no tracked `.fallow/*.bin`), an
|
|
305
306
|
`.oxlintrc.json` that doesn't extend the shared base, and a `lint` block in `vite.config`.
|
|
306
307
|
- **Compose:** an `image:` that's `:latest` or untagged, unless the service builds it.
|
|
308
|
+
- **Untracked imports:** a staged code file whose relative or `#alias` import resolves to a file
|
|
309
|
+
that's on disk but not in the commit and not ignored. `@heyramzi/ui` 2.15.0 shipped that way
|
|
310
|
+
without `lib/motion.ts`.
|
|
307
311
|
- **Fossil names:** an added path named `-old`, `-v2`, `-final` or `copy`, or under `misc/` or
|
|
308
312
|
`temp/`.
|
|
309
313
|
|
|
310
314
|
No allowlist, no config.
|
|
311
315
|
|
|
316
|
+
### Slop Gate and Jev
|
|
317
|
+
|
|
318
|
+
`heyramzi-slop <file|dir|->` runs the exact patterns, and `--register=<name>` adds the rates of a
|
|
319
|
+
voice. `--jev` also asks TypeSafe Jev (`jev.js`) to score each sentence and paragraph against the
|
|
320
|
+
humanizer shapes. Those scores are a report unless `--shape-block=<0.6-1>` names a bar. Jev reads
|
|
321
|
+
`JEV_BASE_URL` and `JEV_API_KEY` from the env, else Proton Pass (Dev vault, item `AI endpoints`).
|
|
322
|
+
A base ending in `/ai/run` is Cloudflare Workers AI, which also reads `JEV_GATEWAY_ID`.
|
|
323
|
+
|
|
324
|
+
`--register=forum` is the Reddit gate, and `reddit lint` in upsys/app runs it. It's built from the
|
|
325
|
+
Reddit bench below, because the humanizer checks refused 151 of 157 human replies there:
|
|
326
|
+
|
|
327
|
+
- **AI signals** (`register.js`): no I, hedge or question; short even sentences; orders to the
|
|
328
|
+
reader; chopped into short paragraphs; no question or aside. Three or more of the 5 fails a reply
|
|
329
|
+
of 25 words or more. `aiSignalNames(text)` lists them.
|
|
330
|
+
- **Ramzi's two rules**: no em or en dash, and no single block over 95 words.
|
|
331
|
+
- **Jev** asks one whole-reply question (`FORUM_SHAPES` in `jev-core.js`) in place of the sentence
|
|
332
|
+
shapes, and refuses at 0.75. The forum register always asks it, and when Jev can't answer the
|
|
333
|
+
reply fails with `jev unscored`. A reply under 25 words asks Jev nothing.
|
|
334
|
+
|
|
335
|
+
`jev-core.js` (`@heyramzi/lint/jev-core`) is the same Jev pass with no Node import, for a Worker:
|
|
336
|
+
`auditShapesWith(text, { post: jevPost({ baseUrl, key, gatewayId }), block: FAIL, register: "forum" })`.
|
|
337
|
+
`jev.js` wraps it for Node with the env, Proton Pass and a disk cache.
|
|
338
|
+
|
|
339
|
+
#### The Reddit bench
|
|
340
|
+
|
|
341
|
+
`data/reddit-bench.json` holds u/heyramzi comments that went badly (`bad: true`) and the top human
|
|
342
|
+
replies in the same threads (`bad: false`). A comment is bad when it was reported (`reported`, by
|
|
343
|
+
id), removed (a mod-team, AutoModerator or BotBouncer notice, or the app's removal record), scored
|
|
344
|
+
0 or less, sits in a sub that banned us or that the app marked cold, or was posted on a day in
|
|
345
|
+
`badDays`. A row, once bad, stays bad. The file stays out of the npm tarball.
|
|
346
|
+
|
|
347
|
+
- `node scripts/reddit-bench.mjs` runs the CLI exactly as `reddit lint` does on every row. It prints
|
|
348
|
+
recall (bad comments refused), the false positive rate (humans refused) and which check caught
|
|
349
|
+
what. It exits 1 when a bad comment outside `knownMisses` passes, or more than 17% of humans are
|
|
350
|
+
refused. After a gate change you've reviewed, `--accept` writes today's misses to `knownMisses`.
|
|
351
|
+
- `scripts/reddit-bench-harvest.mjs` pulls new bad comments and fresh human replies through the
|
|
352
|
+
logged-in Orca tab, one read every 6 seconds, writes them to the bench, then runs the bench and
|
|
353
|
+
exits with its code:
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
cd ~/Studio/vibe-kit && bun ./CLIs/scripts/secrets.mjs run --mode development \
|
|
357
|
+
--file 'CLIs/.env' --shell "bun packages/lint/scripts/reddit-bench-harvest.mjs"
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`--no-bench` stops after the harvest. A new report from a mod or a bot: add the comment id to
|
|
361
|
+
`reported`, then run it. When it fails, change the AI signals or `FORUM_SHAPES` against the whole
|
|
362
|
+
bench, never the one comment, and keep the false positive rate under the bar.
|
|
363
|
+
|
|
312
364
|
### Commit Message Gate
|
|
313
365
|
|
|
314
366
|
`heyramzi-commit-msg <file>` is a `commit-msg` hook. It refuses an em or en dash anywhere in the
|
package/bin/heyramzi-jev-code.js
CHANGED
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* `heyramzi-jev-code <file
|
|
4
|
-
*
|
|
3
|
+
* `heyramzi-jev-code <file...>`. 0.75+ exits 1, 0.6 to 0.75 is listed to double-check, and no key
|
|
4
|
+
* exits 2. Why: TECHLOG.md.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { readFileSync } from "node:fs";
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
|
-
import { join } from "node:path";
|
|
10
8
|
import { JEV_OFF, jevKey } from "#lint/jev.js";
|
|
11
9
|
import { RULES, auditCode } from "#lint/jev-code.js";
|
|
12
10
|
|
|
13
|
-
// =========================
|
|
14
|
-
// CONSTANTS
|
|
15
|
-
// =========================
|
|
16
|
-
const STUDIO = process.env.JEV_CODE_ROOT ?? join(homedir(), "Studio");
|
|
17
|
-
const SKIP =
|
|
18
|
-
/\/(node_modules|dist|build|\.svelte-kit|\.next|coverage|\.claude|\.codex|\.gemini|\.opencode|vendor|generated)\/|\.min\.js$|\.d\.ts$/;
|
|
19
|
-
/** Chunks of 60 lines; a Write of a whole file is judged on its first 240. */
|
|
20
|
-
const MAX_CHARS = 240 * 80;
|
|
21
|
-
const TIMEOUT_MS = 20_000;
|
|
22
|
-
|
|
23
11
|
// =========================
|
|
24
12
|
// FUNCTIONS
|
|
25
13
|
// =========================
|
|
26
|
-
/** The text an Edit, MultiEdit or Write put into the file. */
|
|
27
|
-
export function writtenText(input) {
|
|
28
|
-
if (typeof input.content === "string") return input.content;
|
|
29
|
-
if (typeof input.new_string === "string") return input.new_string;
|
|
30
|
-
if (Array.isArray(input.edits)) return input.edits.map((e) => e.new_string ?? "").join("\n\n");
|
|
31
|
-
return "";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
14
|
function report({ findings, review }, file) {
|
|
35
15
|
const line = (h) => `- ${h.id} (${h.p.toFixed(2)}): ${RULES[h.id].fix}`;
|
|
36
16
|
const out = [];
|
|
@@ -52,37 +32,6 @@ const dedupe = (hits) => [
|
|
|
52
32
|
...new Map(hits.toSorted((a, b) => b.p - a.p).map((h) => [h.id, h])).values(),
|
|
53
33
|
];
|
|
54
34
|
|
|
55
|
-
async function hook() {
|
|
56
|
-
let input;
|
|
57
|
-
try {
|
|
58
|
-
input = JSON.parse(readFileSync(0, "utf8"));
|
|
59
|
-
} catch {
|
|
60
|
-
return 0;
|
|
61
|
-
}
|
|
62
|
-
const file = input.tool_input?.file_path ?? "";
|
|
63
|
-
if (!file.startsWith(`${STUDIO}/`) || SKIP.test(file)) return 0;
|
|
64
|
-
const code = writtenText(input.tool_input).slice(0, MAX_CHARS);
|
|
65
|
-
const k = jevKey();
|
|
66
|
-
if (!code || !k) return 0;
|
|
67
|
-
|
|
68
|
-
const timeout = new Promise((resolve) => setTimeout(() => resolve(null), TIMEOUT_MS).unref());
|
|
69
|
-
const result = await Promise.race([auditCode(code, file, { key: k }).catch(() => null), timeout]);
|
|
70
|
-
if (!result) return 0;
|
|
71
|
-
const hits = { findings: dedupe(result.findings), review: dedupe(result.review) };
|
|
72
|
-
hits.review = hits.review.filter((r) => !hits.findings.some((f) => f.id === r.id));
|
|
73
|
-
if (hits.findings.length) {
|
|
74
|
-
process.stderr.write(`${report(hits, file)}\n`);
|
|
75
|
-
return 2;
|
|
76
|
-
}
|
|
77
|
-
if (hits.review.length) {
|
|
78
|
-
const additionalContext = report(hits, file);
|
|
79
|
-
process.stdout.write(
|
|
80
|
-
JSON.stringify({ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext } }),
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
return 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
35
|
async function files(paths) {
|
|
87
36
|
const k = jevKey();
|
|
88
37
|
if (!k) {
|
|
@@ -101,7 +50,7 @@ async function files(paths) {
|
|
|
101
50
|
|
|
102
51
|
const args = process.argv.slice(2);
|
|
103
52
|
if (!args.length) {
|
|
104
|
-
process.stderr.write("usage: heyramzi-jev-code <file
|
|
53
|
+
process.stderr.write("usage: heyramzi-jev-code <file...>\n");
|
|
105
54
|
process.exit(2);
|
|
106
55
|
}
|
|
107
|
-
process.exit(
|
|
56
|
+
process.exit(await files(args));
|
|
@@ -23,8 +23,18 @@ const git = (args) =>
|
|
|
23
23
|
const all = process.argv.includes("--all");
|
|
24
24
|
|
|
25
25
|
const tracked = git(["ls-files", "-z"]).toString("utf8").split("\0").filter(Boolean);
|
|
26
|
+
const untracked = git(["ls-files", "--others", "--exclude-standard", "-z"])
|
|
27
|
+
.toString("utf8")
|
|
28
|
+
.split("\0")
|
|
29
|
+
.filter(Boolean);
|
|
26
30
|
const changes = all ? { touched: tracked, added: tracked } : staged();
|
|
27
|
-
const tree = createTree({
|
|
31
|
+
const tree = createTree({
|
|
32
|
+
...changes,
|
|
33
|
+
tracked,
|
|
34
|
+
untracked,
|
|
35
|
+
read: all ? readWorking : readStaged,
|
|
36
|
+
readBefore: all ? undefined : readHead,
|
|
37
|
+
});
|
|
28
38
|
|
|
29
39
|
const violations = check(tree);
|
|
30
40
|
if (violations.length === 0) {
|
|
@@ -61,6 +71,15 @@ function readStaged(file) {
|
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
|
|
74
|
+
/** The file as HEAD has it, or null for a new file or a repo with no commit yet. */
|
|
75
|
+
function readHead(file) {
|
|
76
|
+
try {
|
|
77
|
+
return git(["cat-file", "blob", `HEAD:${file}`]).toString("utf8");
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
64
83
|
function readWorking(file) {
|
|
65
84
|
try {
|
|
66
85
|
return readFileSync(path.join(repoRoot, file), "utf8");
|
package/bin/heyramzi-slop.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
50
|
/*
|
|
51
|
-
* With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs.
|
|
51
|
+
* With the model unreachable the exact patterns still run, stderr says the model check didn't, and the exit code is theirs. `--register=forum` is the exception: it always asks Jev and fails when Jev can't answer.
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -56,7 +56,8 @@ 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 {
|
|
59
|
+
import { FAIL, REVIEW, isUnavailable, proseOf } from "#lint/jev-core.js";
|
|
60
|
+
import { auditShapes, jevKey as readJevKey } from "#lint/jev.js";
|
|
60
61
|
import { slopGate } from "#lint/slop.js";
|
|
61
62
|
|
|
62
63
|
// =========================
|
|
@@ -149,7 +150,7 @@ async function modelShapes(file, raw) {
|
|
|
149
150
|
try {
|
|
150
151
|
jevKey ??= readJevKey();
|
|
151
152
|
const text = /\.(html?|svelte|vue)$/i.test(file) ? proseOf(raw) : raw;
|
|
152
|
-
return await auditShapes(text, { key: jevKey, block: shapeBlock });
|
|
153
|
+
return await auditShapes(text, { key: jevKey, block: shapeBlock, register });
|
|
153
154
|
} catch (err) {
|
|
154
155
|
if (!isUnavailable(err)) throw err;
|
|
155
156
|
jevDown = err.message;
|
|
@@ -211,12 +212,17 @@ if (onlyFlag && !onlyFlag.includes("=")) {
|
|
|
211
212
|
}
|
|
212
213
|
const only = onlyFlag ? new Set(onlyFlag.split("=")[1].split(",").filter(Boolean)) : null;
|
|
213
214
|
|
|
215
|
+
// The reply BotBouncer reported on 30 Oct 2026 passed every exact pattern. So forum always asks
|
|
216
|
+
// Jev, refuses at FAIL, and fails a reply Jev couldn't score.
|
|
217
|
+
const forum = register === "forum";
|
|
218
|
+
const askJev = flags.has("--jev") || forum;
|
|
219
|
+
|
|
214
220
|
// The opt-in bar. Below REVIEW would promise to block scores the model check never keeps.
|
|
215
221
|
const blockFlag = args.find((a) => a.startsWith("--shape-block"));
|
|
216
|
-
let shapeBlock = Infinity;
|
|
222
|
+
let shapeBlock = forum ? FAIL : Infinity;
|
|
217
223
|
if (blockFlag) {
|
|
218
224
|
shapeBlock = blockFlag.includes("=") ? Number(blockFlag.split("=")[1]) : Number.NaN;
|
|
219
|
-
if (!(shapeBlock >= REVIEW && shapeBlock <= 1) || !
|
|
225
|
+
if (!(shapeBlock >= REVIEW && shapeBlock <= 1) || !askJev) {
|
|
220
226
|
process.stderr.write(
|
|
221
227
|
`--shape-block takes a score from ${REVIEW} to 1 and needs --jev: --jev --shape-block=0.85\n`,
|
|
222
228
|
);
|
|
@@ -238,7 +244,7 @@ for (const file of files) {
|
|
|
238
244
|
result.review = [];
|
|
239
245
|
result.ok = result.findings.length === 0;
|
|
240
246
|
}
|
|
241
|
-
if (
|
|
247
|
+
if (askJev && !jevDown) {
|
|
242
248
|
const found = await modelShapes(file, raw);
|
|
243
249
|
if (found) {
|
|
244
250
|
result.findings.push(...found.findings);
|
|
@@ -246,7 +252,15 @@ for (const file of files) {
|
|
|
246
252
|
result.ok = result.ok && found.findings.length === 0;
|
|
247
253
|
}
|
|
248
254
|
}
|
|
249
|
-
if (
|
|
255
|
+
if (askJev) result.jev = jevDown ? { ran: false, reason: jevDown } : { ran: true };
|
|
256
|
+
if (forum && jevDown) {
|
|
257
|
+
result.findings.push({
|
|
258
|
+
kind: "jev",
|
|
259
|
+
id: "unscored",
|
|
260
|
+
detail: `a forum reply needs Jev: ${jevDown}`,
|
|
261
|
+
});
|
|
262
|
+
result.ok = false;
|
|
263
|
+
}
|
|
250
264
|
results.push({ file, raw, result });
|
|
251
265
|
|
|
252
266
|
if (flags.has("--fix") && result.removed.length > 0) {
|
|
@@ -279,7 +293,9 @@ const ok = results.every((r) => r.result.ok) && !ledger;
|
|
|
279
293
|
// Said on stderr in every mode, so a quiet or JSON run never reads as a full pass.
|
|
280
294
|
if (jevDown)
|
|
281
295
|
process.stderr.write(
|
|
282
|
-
|
|
296
|
+
forum
|
|
297
|
+
? `model check did not run: ${jevDown}. A forum reply fails without it.\n`
|
|
298
|
+
: `model check did not run: ${jevDown}. Exact patterns only; the exit code is theirs alone.\n`,
|
|
283
299
|
);
|
|
284
300
|
|
|
285
301
|
if (flags.has("--json")) {
|
package/data/jev-bench.js
CHANGED
|
@@ -93,6 +93,14 @@ export const SENTENCES = [
|
|
|
93
93
|
{ shape: null, text: "Does Friday at 10am still work for you and your accountant?" },
|
|
94
94
|
{ shape: null, text: "Thanks for sending the floor plan so fast." },
|
|
95
95
|
{ shape: null, text: "We'd love to have you at the tasting next week." },
|
|
96
|
+
{
|
|
97
|
+
shape: "reassurance",
|
|
98
|
+
text: "Every photo of the bread here is my own loaf, straight from my oven.",
|
|
99
|
+
},
|
|
100
|
+
{ shape: "reassurance", text: "The payroll numbers below are real, nothing rounded up." },
|
|
101
|
+
{ shape: "reassurance", text: "These are real reviews from real gym members, no paid ones." },
|
|
102
|
+
{ shape: null, text: "I own the bakery that sells this flour." },
|
|
103
|
+
{ shape: null, text: "The supplier sent me the mixer for free to review." },
|
|
96
104
|
];
|
|
97
105
|
|
|
98
106
|
export const PARAGRAPHS = [
|
|
@@ -63,7 +63,7 @@ export const patternsNumbersAndRuns = [
|
|
|
63
63
|
|
|
64
64
|
// or it is 2 items, or it is bullets.
|
|
65
65
|
view: "prose",
|
|
66
|
-
test: /(?:^|[.!?:\n]\s*)(?![^.!?\n]*(?:\b(?:and|or|but|nor|then|so|plus|et|ou|mais|ni|puis|donc)\b|=>))[^.!?\n,]{4,40},\s[^.!?\n,]{4,40},\s[^.!?\n,]{4,40}(?=[.!?\n]|$)/i,
|
|
66
|
+
test: /(?:^|[.!?:\n]\s*)(?![^.!?\n]*(?:\b(?:and|or|but|nor|then|so|plus|et|ou|mais|ni|puis|donc|y|e|o|pero|mas)\b|=>))[^.!?\n,]{4,40},\s[^.!?\n,]{4,40},\s[^.!?\n,]{4,40}(?=[.!?\n]|$)/i,
|
|
67
67
|
rule: "Three or more fragments hung on commas with no conjunction. It reads as a machine emptying a list rather than a person making a point: nothing in it is subordinate to anything else, so the reader has no idea which part matters. Use two items and a conjunction, or write bullets.",
|
|
68
68
|
example:
|
|
69
69
|
'"One connector, read the permission screen, 12 slides back." / "Fast, cheap, reliable." / "The brief, the offer, the tone."',
|
|
@@ -56,6 +56,13 @@ export const shapesFraming = [
|
|
|
56
56
|
example:
|
|
57
57
|
'"If you are coming from traditional automation: instead of registering handlers, you describe conditions." / "The rule is simple: write it down." / "Here is the tradeoff: speed against accuracy."',
|
|
58
58
|
},
|
|
59
|
+
{
|
|
60
|
+
id: "unprompted-reassurance",
|
|
61
|
+
name: "Unprompted reassurance",
|
|
62
|
+
rule: 'A sentence whose only job is to fend off a suspicion nobody has raised: that the content is fake, staged, mocked up, written by AI, sponsored, edited or dishonest. It reads as a bot pre-empting the exact accusation, so it plants the doubt it was meant to settle. Ramzi, 2 Nov 2026, on a Reddit launch post that said every screen in the video was the real app: "saying this is so stupid in the 1st place because it sounds AI generated", and "They focus on details instead of looking at the big picture of things." Cut the sentence, or show the proof instead of asserting it: a link to the build, the changelog, a release count the reader can check. A disclosure the venue asks for ("I\'m the developer", "they sent me a review unit") states a relationship and stays. Jev judges it as `reassurance`. Not in `patterns` because the same words are literal elsewhere: "the designer sent no mockups" and "no fluff in the sauce" describe a thing, not the writing.',
|
|
63
|
+
example:
|
|
64
|
+
'"Everything in the video is the real app, no mockups." / "This isn\'t an ad, I just love it." / "100% real footage." / "Real numbers, no cherry-picking." / "Screenshots are unedited, I promise." / "No fluff, just what worked."',
|
|
65
|
+
},
|
|
59
66
|
{
|
|
60
67
|
id: "abstract-metaphor-noun",
|
|
61
68
|
name: "Abstract metaphor noun",
|
package/file-tokens.js
CHANGED
|
@@ -37,7 +37,7 @@ export const GENERATED_TREES = [
|
|
|
37
37
|
export const DEFAULT_IGNORED = [
|
|
38
38
|
...GENERATED_TREES,
|
|
39
39
|
"raw",
|
|
40
|
-
// Boards are one document per subject by
|
|
40
|
+
// Boards are one document per subject by ai-doc/references/playground.md, and `playground check` gates them.
|
|
41
41
|
"playground",
|
|
42
42
|
];
|
|
43
43
|
|
package/inline-path.js
CHANGED
|
@@ -29,7 +29,7 @@ export const DEFAULT_IGNORED = [
|
|
|
29
29
|
".claude",
|
|
30
30
|
".next",
|
|
31
31
|
"static",
|
|
32
|
-
// Boards draw their diagrams inline by
|
|
32
|
+
// Boards draw their diagrams inline by ai-doc/references/playground.md, and `playground check` gates them.
|
|
33
33
|
"playground",
|
|
34
34
|
];
|
|
35
35
|
|
package/jev-code.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Coding guidelines as tiny Jev questions, judged on the edited code alone after each edit.
|
|
3
3
|
* Only rules a reader can settle from the snippet, no repo context. Bench: scripts/jev-code-bench.mjs.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { q } from "#lint/jev-core.js";
|
|
6
|
+
import { JEV_OFF, jevKey, judge } from "#lint/jev.js";
|
|
6
7
|
|
|
7
8
|
// =========================
|
|
8
9
|
// CONSTANTS
|
package/jev-core.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** One Jev yes/no question, scored 0 to 1 as the chance the answer is yes. */
|
|
2
|
+
export type JevQuestion = {
|
|
3
|
+
type: "noul";
|
|
4
|
+
instructions: string;
|
|
5
|
+
criteria: { true: string; false: string };
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/** What a caller's `post` sends to Jev: items keyed `i<n>`, questions keyed `i<n>_<shape>`. */
|
|
9
|
+
export type JevRequest = {
|
|
10
|
+
state: Record<string, Record<string, string>>;
|
|
11
|
+
questions: Record<string, JevQuestion>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** Jev's `answers`, keyed like the questions. `post` returns this object, unwrapped from any envelope. */
|
|
15
|
+
export type JevAnswers = Record<string, { noul?: number }>;
|
|
16
|
+
|
|
17
|
+
/** Sends one request to Jev. Throw `unavailable(message)` when it can't answer. */
|
|
18
|
+
export type JevPost = (request: JevRequest) => Promise<JevAnswers>;
|
|
19
|
+
|
|
20
|
+
/** Optional score store: `read` returns earlier worst scores or undefined, `write` keeps them. */
|
|
21
|
+
export type JevCache = {
|
|
22
|
+
read: (
|
|
23
|
+
item: Record<string, string>,
|
|
24
|
+
field: string,
|
|
25
|
+
shapes: Record<string, JevQuestion>,
|
|
26
|
+
) => Record<string, number> | undefined;
|
|
27
|
+
write: (
|
|
28
|
+
item: Record<string, string>,
|
|
29
|
+
field: string,
|
|
30
|
+
shapes: Record<string, JevQuestion>,
|
|
31
|
+
scores: Record<string, number>,
|
|
32
|
+
) => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ShapeHit = { p: number; kind: "shape"; id: string; detail: string };
|
|
36
|
+
export type ShapeResult = { findings: ShapeHit[]; review: ShapeHit[] };
|
|
37
|
+
|
|
38
|
+
/** Jev's moving id on TypeSafe-compatible gateways, and on Cloudflare Workers AI. */
|
|
39
|
+
export const MODEL: "typesafe-ai/jev";
|
|
40
|
+
export const CLOUDFLARE_MODEL: "typesafe/jev";
|
|
41
|
+
|
|
42
|
+
/** A base URL ending in `/ai/run` is Cloudflare; anything else gets `/v1/systemone`. */
|
|
43
|
+
export function jevRoute(baseUrl: string): { url: string; model: string; cloudflare: boolean };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A `JevPost` over fetch for any runtime, a Worker included. `gatewayId` is the Cloudflare AI
|
|
47
|
+
* Gateway id; `fetch` defaults to the global one. Retries a 429 or 5xx 4 times, then throws.
|
|
48
|
+
*/
|
|
49
|
+
export function jevPost(options: {
|
|
50
|
+
baseUrl: string;
|
|
51
|
+
key: string;
|
|
52
|
+
gatewayId?: string;
|
|
53
|
+
fetch?: typeof fetch;
|
|
54
|
+
}): JevPost;
|
|
55
|
+
|
|
56
|
+
/** The bar a gate refuses at, and the floor a score is reported from. */
|
|
57
|
+
export const FAIL: 0.75;
|
|
58
|
+
export const REVIEW: 0.6;
|
|
59
|
+
/** A forum reply shorter than this gets no whole-reply questions. */
|
|
60
|
+
export const FORUM_MIN_WORDS: number;
|
|
61
|
+
|
|
62
|
+
export function q(instructions: string, yes: string, no: string): JevQuestion;
|
|
63
|
+
|
|
64
|
+
/** Asked of every sentence (`sentence`, with its paragraph as `context`). */
|
|
65
|
+
export const SHAPES: Record<string, JevQuestion>;
|
|
66
|
+
/** Asked of every paragraph of 3 sentences or more (`paragraph`). */
|
|
67
|
+
export const PARAGRAPH_SHAPES: Record<string, JevQuestion>;
|
|
68
|
+
/** Asked once of a whole forum reply (`reply`) under `register: "forum"`, in place of the other two. */
|
|
69
|
+
export const FORUM_SHAPES: Record<string, JevQuestion>;
|
|
70
|
+
|
|
71
|
+
export function sentences(text: string): { sentence: string; context: string }[];
|
|
72
|
+
export function paragraphs(text: string): { paragraph: string }[];
|
|
73
|
+
export function replies(text: string): { reply: string }[];
|
|
74
|
+
export function proseOf(html: string): string;
|
|
75
|
+
|
|
76
|
+
export function unavailable(message: string): Error;
|
|
77
|
+
export function isUnavailable(err: unknown): boolean;
|
|
78
|
+
|
|
79
|
+
export function judgeWith(
|
|
80
|
+
items: Record<string, string>[],
|
|
81
|
+
shapes: Record<string, JevQuestion>,
|
|
82
|
+
field: string,
|
|
83
|
+
options: { post: JevPost; cache?: JevCache; block?: number },
|
|
84
|
+
): Promise<ShapeResult>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The CLI's Jev pass with your transport. `block: FAIL` and `register: "forum"` is the Reddit gate;
|
|
88
|
+
* a finding means refuse. Throws when `post` throws.
|
|
89
|
+
*/
|
|
90
|
+
export function auditShapesWith(
|
|
91
|
+
text: string,
|
|
92
|
+
options: { post: JevPost; cache?: JevCache; block?: number; register?: string },
|
|
93
|
+
): Promise<ShapeResult>;
|