@heyramzi/lint 2.2.0 → 2.2.1

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.
@@ -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, kiloKey } from "#lint/jev.js";
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 = kiloKey();
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 = kiloKey();
87
+ const k = gatewayKey();
88
88
  if (!k) {
89
89
  process.stderr.write(`heyramzi-jev-code ${NO_KEY}\n`);
90
90
  return 2;
@@ -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, kiloKey, proseOf } from "#lint/jev.js";
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 ??= kiloKey();
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) {
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.KILO_API_KEY } = {}) {
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 Kilo gateway. Bench: scripts/jev-bench.mjs. Why these shapes: TECHLOG.md.
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 Kilo, which bills our Kilo credits and pins the model. */
16
- const KILO_URL = "https://api.kilo.ai/api/gateway/typesafe/v1/systemone";
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
- /** Kilo only takes the pinned name; `jev-latest` answers 400 model_not_found. */
20
- export const MODEL = "typesafe/jev-1.13";
21
- export const NO_KEY = "needs KILO_API_KEY (Proton Pass, Dev vault, item Kilo)";
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
- /** `KILO_API_KEY` from the env, else Proton Pass (Dev vault, item Kilo), else "". */
164
- export function kiloKey() {
165
- if (process.env.KILO_API_KEY) return process.env.KILO_API_KEY;
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
- ["item", "view", "--vault-name", "Dev", "--item-title", "Kilo", "--field", "password"],
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 || KILO_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(text, { key = process.env.KILO_API_KEY, block = Infinity } = {}) {
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.2.0",
3
+ "version": "2.2.1",
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.0"
83
+ "@heyramzi/social": "^1.2.1"
84
84
  },
85
85
  "scripts": {
86
86
  "voice:refresh": "node scripts/harvest-voice.mjs --write",
@@ -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 KILO_API_KEY, from the env or Proton Pass (Dev vault, item Kilo).
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, kiloKey } from "#lint/jev.js";
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 = kiloKey();
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 KILO_API_KEY (env or Proton Pass). Why: TECHLOG.md.
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 { kiloKey } from "#lint/jev.js";
7
+ import { gatewayKey } from "#lint/jev.js";
8
8
 
9
9
  const set = process.argv[2] ?? "all";
10
- const key = kiloKey();
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 };