@r_masseater/oxlint-plugin-decision 0.7.0 → 0.8.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 +12 -3
- package/dist/{app-Bso1uwY5.mjs → app-UakaWKAT.mjs} +57 -73
- package/dist/app-UakaWKAT.mjs.map +1 -0
- package/dist/cloudflare-worker.mjs +2 -3
- package/dist/cloudflare-worker.mjs.map +1 -1
- package/dist/{decision-BtTZ52be.mjs → decision-B7hahWHz.mjs} +48 -130
- package/dist/decision-B7hahWHz.mjs.map +1 -0
- package/dist/{define-presets-clyqLZxo.mjs → define-presets-yflVt8vT.mjs} +3 -3
- package/dist/{define-presets-clyqLZxo.mjs.map → define-presets-yflVt8vT.mjs.map} +1 -1
- package/dist/{index-Cgg-w0hb.d.mts → index-C0Twu0w7.d.mts} +26 -31
- package/dist/{index-BOrpK3Iv.d.mts → index-HOwrGbIA.d.mts} +2 -2
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +1 -1
- package/dist/{preset-plugin-AAwedMeS.mjs → preset-plugin-ClpEFUN5.mjs} +2 -2
- package/dist/{preset-plugin-AAwedMeS.mjs.map → preset-plugin-ClpEFUN5.mjs.map} +1 -1
- package/dist/presets/ai-slop.d.mts +2 -3
- package/dist/presets/ai-slop.mjs +2 -2
- package/dist/presets/index.d.mts +1 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/recommended.d.mts +1 -2
- package/dist/presets/recommended.mjs +2 -2
- package/dist/presets/review-only.d.mts +1 -2
- package/dist/presets/review-only.mjs +2 -2
- package/dist/presets/strict.d.mts +1 -2
- package/dist/presets/strict.mjs +2 -2
- package/dist/{serve-decisions-CjlhvYm7.mjs → serve-decisions-DYGwLMft.mjs} +86 -89
- package/dist/serve-decisions-DYGwLMft.mjs.map +1 -0
- package/dist/typesafe-worker.mjs +11 -0
- package/dist/typesafe-worker.mjs.map +1 -0
- package/package.json +5 -10
- package/skills/write-decision-rules/SKILL.md +6 -6
- package/skills/write-decision-rules/references/tuning.md +1 -3
- package/dist/app-Bso1uwY5.mjs.map +0 -1
- package/dist/decision-BtTZ52be.mjs.map +0 -1
- package/dist/index-D7VrRpTx.d.mts +0 -6
- package/dist/openrouter-app.d.mts +0 -19
- package/dist/openrouter-app.mjs +0 -1
- package/dist/openrouter-worker.mjs +0 -15
- package/dist/openrouter-worker.mjs.map +0 -1
- package/dist/serve-decisions-CjlhvYm7.mjs.map +0 -1
- package/skills/write-decision-rules/references/providers.md +0 -55
- /package/dist/{openrouter-worker.d.mts → typesafe-worker.d.mts} +0 -0
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as AnswerSchema, a as envNameOf, c as messageOf, d as toJson, h as parseVerdicts, i as captured, n as mergeResponses, y as PREFIX } from "./decision-B7hahWHz.mjs";
|
|
2
2
|
import { Array, Clock, Config, Effect, FileSystem, Function, Layer, Option, Path, Schedule, Schema, String as String$1, pipe } from "effect";
|
|
3
3
|
import { runAsWorker } from "synckit";
|
|
4
|
-
import { Answer } from "@effect/ai-openrouter/OpenRouterSchema";
|
|
5
4
|
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
|
|
6
|
-
import { make } from "@effect/ai-openrouter/OpenRouterClient";
|
|
7
5
|
import { Digest } from "effect/crypto";
|
|
8
6
|
import { layerDigest } from "@effect/platform-node-shared/NodeCrypto";
|
|
9
7
|
import { layer } from "@effect/platform-node-shared/NodeFileSystem";
|
|
10
8
|
import { layer as layer$1 } from "@effect/platform-node-shared/NodePath";
|
|
11
9
|
import { OtlpSerialization, OtlpTracer } from "effect/observability";
|
|
12
|
-
// src/features/serve-decisions/model/
|
|
13
|
-
const GITHUB = "https://github.com";
|
|
10
|
+
// src/features/serve-decisions/model/app-context.ts
|
|
14
11
|
const SELF = "masseater/masseater.dev";
|
|
15
12
|
const GIT_SUFFIX = /\.git\/?$/u;
|
|
16
13
|
const SEPARATORS = /[/:]/u;
|
|
@@ -82,112 +79,112 @@ const appContext = Effect.gen(function* app() {
|
|
|
82
79
|
context
|
|
83
80
|
};
|
|
84
81
|
});
|
|
82
|
+
// src/features/serve-decisions/model/system-one.ts
|
|
83
|
+
const FIRST_REDIRECT = 300;
|
|
84
|
+
const RETRY_INITIAL_MS = 10;
|
|
85
|
+
const RETRY_EXPONENT = 2;
|
|
86
|
+
const Decisions = Schema.Struct({
|
|
87
|
+
model: Schema.String,
|
|
88
|
+
answers: Schema.Record(Schema.String, AnswerSchema)
|
|
89
|
+
});
|
|
90
|
+
const Envelope = Schema.Struct({ result: Decisions });
|
|
91
|
+
const ErrorMessage = Schema.Struct({ message: Schema.String });
|
|
92
|
+
const ErrorBody = Schema.Union([Schema.Struct({ errors: Schema.NonEmptyArray(ErrorMessage) }), Schema.Struct({ detail: ErrorMessage })]);
|
|
93
|
+
const decodeErrorBody = Schema.decodeUnknownOption(ErrorBody);
|
|
94
|
+
const messageOfBody = (body) => Option.match(decodeErrorBody(body), {
|
|
95
|
+
onNone: () => "request failed",
|
|
96
|
+
onSome: (decoded) => {
|
|
97
|
+
if ("detail" in decoded) return decoded.detail.message;
|
|
98
|
+
return pipe(decoded.errors, Array.map(({ message }) => message), Array.join("; "));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const failureOf = (response) => response.json.pipe(Effect.option, Effect.flatMap((body) => Effect.fail(`http ${String(response.status)}: ${messageOfBody(Option.getOrUndefined(body))}`)));
|
|
102
|
+
const decodeEnvelope = HttpClientResponse.schemaBodyJson(Envelope);
|
|
103
|
+
const decodeDecisions = HttpClientResponse.schemaBodyJson(Decisions);
|
|
104
|
+
const invalid = ({ message }) => `invalid response: ${message}`;
|
|
105
|
+
const decisionsOf = (response, envelope) => {
|
|
106
|
+
if (envelope) return decodeEnvelope(response).pipe(Effect.mapBoth({
|
|
107
|
+
onSuccess: ({ result }) => result,
|
|
108
|
+
onFailure: invalid
|
|
109
|
+
}));
|
|
110
|
+
return decodeDecisions(response).pipe(Effect.mapError(invalid));
|
|
111
|
+
};
|
|
85
112
|
/** @internal */
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
113
|
+
const sendSystemOne = Effect.fn("sendSystemOne")(function* sendSystemOne(call, wire) {
|
|
114
|
+
const client = (yield* HttpClient.HttpClient).pipe(HttpClient.retryTransient({
|
|
115
|
+
retryOn: "response-only",
|
|
116
|
+
schedule: Schedule.exponential(RETRY_INITIAL_MS, RETRY_EXPONENT)
|
|
117
|
+
}));
|
|
118
|
+
const response = yield* HttpClientRequest.post(call.url).pipe(HttpClientRequest.bearerToken(call.token), HttpClientRequest.setHeaders(call.headers), HttpClientRequest.bodyJsonUnsafe({
|
|
119
|
+
model: call.model,
|
|
120
|
+
state: wire.state,
|
|
121
|
+
questions: wire.questions
|
|
122
|
+
}), client.execute, Effect.mapError(({ message }) => `network: ${message}`));
|
|
123
|
+
if (response.status >= FIRST_REDIRECT) return yield* failureOf(response);
|
|
124
|
+
const decisions = yield* decisionsOf(response, call.envelope);
|
|
90
125
|
return {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"X-OpenRouter-App-Visibility": "hidden"
|
|
126
|
+
model: decisions.model,
|
|
127
|
+
answers: decisions.answers
|
|
94
128
|
};
|
|
95
129
|
});
|
|
96
130
|
// src/features/serve-decisions/model/workers-ai.ts
|
|
97
|
-
const
|
|
98
|
-
const GATEWAY = "default";
|
|
131
|
+
const DEFAULT_GATEWAY = "default";
|
|
99
132
|
const DEFAULT_API_URL = "https://api.cloudflare.com/client/v4";
|
|
100
133
|
const RUN_PATH = "/ai/run";
|
|
101
|
-
const TRAILING_SLASHES = /\/+$/u;
|
|
134
|
+
const TRAILING_SLASHES$1 = /\/+$/u;
|
|
102
135
|
const MODEL_NAME = /(?<name>[^/]+)$/u;
|
|
103
|
-
const
|
|
104
|
-
const RETRY_INITIAL_MS$1 = 10;
|
|
105
|
-
const RETRY_EXPONENT$1 = 2;
|
|
106
|
-
const Decisions = Schema.Struct({
|
|
107
|
-
model: Schema.String,
|
|
108
|
-
answers: Schema.Record(Schema.String, Answer)
|
|
109
|
-
});
|
|
110
|
-
const RunBody = Schema.Struct({ body: Schema.Struct({ result: Decisions }) });
|
|
111
|
-
const ErrorBody$1 = Schema.Struct({ errors: Schema.NonEmptyArray(Schema.Struct({ message: Schema.String })) });
|
|
112
|
-
const decodeErrorBody$1 = Schema.decodeUnknownOption(ErrorBody$1);
|
|
113
|
-
const accountUrl = ({ api, account }) => `${String$1.replace(TRAILING_SLASHES, "")(String$1.trim(api))}/accounts/${String$1.trim(account)}`;
|
|
136
|
+
const accountUrl = ({ api, account }) => `${String$1.replace(TRAILING_SLASHES$1, "")(String$1.trim(api))}/accounts/${String$1.trim(account)}`;
|
|
114
137
|
/** @internal */
|
|
115
138
|
const endpointOf = (env) => Config.all({
|
|
116
139
|
api: Config.String(envNameOf(env, "CLOUDFLARE_API_BASE_URL")).pipe(Config.withDefault(DEFAULT_API_URL)),
|
|
117
140
|
account: Config.NonEmptyString(envNameOf(env, "CLOUDFLARE_ACCOUNT_ID"))
|
|
118
141
|
}).pipe(Config.map(accountUrl));
|
|
119
142
|
const modelNameOf = (model) => Option.getOrElse(captured(String$1.match(MODEL_NAME)(model), "name"), () => model);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
onSome: ({ errors }) => pipe(errors, Array.map(({ message }) => message), Array.join("; "))
|
|
123
|
-
});
|
|
124
|
-
const failureOf = (response) => response.json.pipe(Effect.option, Effect.flatMap((body) => Effect.fail(`http ${String(response.status)}: ${messageOfBody(Option.getOrUndefined(body))}`)));
|
|
125
|
-
const workersAiRequest = (endpoint, wire) => HttpClientRequest.post(`${endpoint}${RUN_PATH}/${wire.model}`).pipe(HttpClientRequest.bodyJsonUnsafe({
|
|
126
|
-
model: modelNameOf(wire.model),
|
|
127
|
-
state: wire.state,
|
|
128
|
-
questions: wire.questions
|
|
129
|
-
}));
|
|
130
|
-
const post = Effect.fn("post")(function* post(endpoint, wire, { env }) {
|
|
143
|
+
/** @internal */
|
|
144
|
+
const sendWorkersAi = Effect.fn("sendWorkersAi")(function* sendWorkersAi(endpoint, wire, { env }) {
|
|
131
145
|
const token = yield* Config.Redacted(envNameOf(env, "CLOUDFLARE_API_TOKEN"));
|
|
146
|
+
const gateway = yield* Config.NonEmptyString(envNameOf(env, "CLOUDFLARE_AI_GATEWAY_ID")).pipe(Config.withDefault(DEFAULT_GATEWAY));
|
|
132
147
|
const app = yield* appContext;
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const sendWorkersAi = Effect.fn("sendWorkersAi")(function* sendWorkersAi(endpoint, wire, input) {
|
|
147
|
-
const response = yield* post(endpoint, wire, input).pipe(Effect.mapError((error) => `network: ${error.message}`));
|
|
148
|
-
if (response.status >= FIRST_REDIRECT) return yield* failureOf(response);
|
|
149
|
-
const run = yield* HttpClientResponse.schemaJson(RunBody)(response).pipe(Effect.mapError((error) => `invalid response: ${error.message}`));
|
|
148
|
+
const decided = yield* sendSystemOne({
|
|
149
|
+
url: `${endpoint}${RUN_PATH}/${wire.model}`,
|
|
150
|
+
model: modelNameOf(wire.model),
|
|
151
|
+
token,
|
|
152
|
+
headers: {
|
|
153
|
+
"cf-aig-gateway-id": gateway,
|
|
154
|
+
"cf-aig-metadata": toJson({
|
|
155
|
+
tool: PREFIX,
|
|
156
|
+
...app
|
|
157
|
+
})
|
|
158
|
+
},
|
|
159
|
+
envelope: true
|
|
160
|
+
}, wire);
|
|
150
161
|
return {
|
|
151
162
|
model: wire.model,
|
|
152
|
-
answers:
|
|
163
|
+
answers: decided.answers
|
|
153
164
|
};
|
|
154
165
|
});
|
|
155
|
-
// src/features/serve-decisions/model/
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
const ErrorBody = Schema.Struct({ error: Schema.Struct({ message: Schema.String }) });
|
|
162
|
-
const decodeErrorBody = Schema.decodeOption(Schema.fromJsonString(ErrorBody));
|
|
163
|
-
const serverMessageOf = (body, fallback) => Option.fromUndefinedOr(body).pipe(Option.flatMap(decodeErrorBody), Option.match({
|
|
164
|
-
onNone: () => fallback,
|
|
165
|
-
onSome: ({ error }) => error.message
|
|
166
|
-
}));
|
|
167
|
-
const reasonFor = ({ _tag, message, http }) => Option.fromUndefinedOr(http).pipe(Option.flatMap(({ response, body }) => Option.map(Option.fromUndefinedOr(response), ({ status }) => `http ${String(status)}: ${serverMessageOf(body, _tag)}`)), Option.getOrElse(() => `network: ${message}`));
|
|
166
|
+
// src/features/serve-decisions/model/typesafe.ts
|
|
167
|
+
const DEFAULT_BASE_URL = "https://api.typesafe.ai";
|
|
168
|
+
const SYSTEM_ONE_PATH = "/v1/systemone";
|
|
169
|
+
const TRAILING_SLASHES = /\/+$/u;
|
|
170
|
+
/** @internal */
|
|
171
|
+
const typesafeEndpointOf = (env) => Config.String(envNameOf(env, "TYPESAFE_BASE_URL")).pipe(Config.withDefault(DEFAULT_BASE_URL), Config.map((url) => String$1.replace(TRAILING_SLASHES, "")(String$1.trim(url))));
|
|
168
172
|
/** @internal */
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}))
|
|
179
|
-
})).createDecisions(decisionsRequest).pipe(Effect.mapError(({ reason }) => reasonFor(reason)));
|
|
180
|
-
return body;
|
|
173
|
+
const sendTypesafe = Effect.fn("sendTypesafe")(function* sendTypesafe(endpoint, wire, { env }) {
|
|
174
|
+
const token = yield* Config.Redacted(envNameOf(env, "TYPESAFE_API_KEY"));
|
|
175
|
+
return yield* sendSystemOne({
|
|
176
|
+
url: `${endpoint}${SYSTEM_ONE_PATH}`,
|
|
177
|
+
model: wire.model,
|
|
178
|
+
token,
|
|
179
|
+
headers: {},
|
|
180
|
+
envelope: false
|
|
181
|
+
}, wire);
|
|
181
182
|
});
|
|
182
183
|
// src/features/serve-decisions/model/cache.ts
|
|
183
184
|
const DATA_FIRST_ARITY = 2;
|
|
184
185
|
const CACHE_VERSION = 7;
|
|
185
186
|
/** @internal */
|
|
186
|
-
const CACHE_DIR =
|
|
187
|
-
"node_modules",
|
|
188
|
-
".cache",
|
|
189
|
-
"oxlint-plugin-decision"
|
|
190
|
-
];
|
|
187
|
+
const CACHE_DIR = `node_modules/.cache/${PREFIX}`;
|
|
191
188
|
const encodeJson = (value) => Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(value).pipe(Effect.orDie);
|
|
192
189
|
/** @internal */
|
|
193
190
|
const cacheFile = Effect.fn("cacheFile")(function* cacheFile(endpoint, request) {
|
|
@@ -200,7 +197,7 @@ const cacheFile = Effect.fn("cacheFile")(function* cacheFile(endpoint, request)
|
|
|
200
197
|
});
|
|
201
198
|
const payload = new TextEncoder().encode(json);
|
|
202
199
|
const hash = yield* digest.digestHex(Digest.sha256, payload);
|
|
203
|
-
return path.resolve(
|
|
200
|
+
return path.resolve(CACHE_DIR, `${hash}.json`);
|
|
204
201
|
});
|
|
205
202
|
const CachedResponse = Schema.Struct({
|
|
206
203
|
model: Schema.NonEmptyString,
|
|
@@ -240,7 +237,7 @@ const ask = Effect.fn("ask")(function* ask(transport, endpoint, { request, timeo
|
|
|
240
237
|
duration: timeoutMs,
|
|
241
238
|
orElse: () => Effect.fail("timeout")
|
|
242
239
|
}));
|
|
243
|
-
return
|
|
240
|
+
return mergeResponses(responses);
|
|
244
241
|
});
|
|
245
242
|
const askAndStore = Effect.fn("askAndStore")(function* askAndStore(transport, { endpoint, file }, input) {
|
|
246
243
|
const response = yield* ask(transport, endpoint, input);
|
|
@@ -285,6 +282,6 @@ const decideEach = (transport, inputs) => Effect.all(pipe(inputs, Array.map((inp
|
|
|
285
282
|
const serveDecisions = (transport) => {
|
|
286
283
|
runAsWorker((inputs) => Effect.runPromise(decideEach(transport, inputs)));
|
|
287
284
|
};
|
|
288
|
-
export {
|
|
285
|
+
export { sendWorkersAi as a, endpointOf as i, sendTypesafe as n, typesafeEndpointOf as r, serveDecisions as t };
|
|
289
286
|
|
|
290
|
-
//# sourceMappingURL=serve-decisions-
|
|
287
|
+
//# sourceMappingURL=serve-decisions-DYGwLMft.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve-decisions-DYGwLMft.mjs","names":["Str","Arr","Arr","TRAILING_SLASHES","Str","Str","Fn","fileSystem","path","Arr"],"sources":["../src/features/serve-decisions/model/app-context.ts","../src/features/serve-decisions/model/system-one.ts","../src/features/serve-decisions/model/workers-ai.ts","../src/features/serve-decisions/model/typesafe.ts","../src/features/serve-decisions/model/cache.ts","../src/features/serve-decisions/model/services.ts","../src/features/serve-decisions/model/serve-decisions.ts"],"sourcesContent":["import {\n Array as Arr,\n Config,\n Effect,\n FileSystem,\n Option,\n Path,\n String as Str,\n pipe,\n} from \"effect\";\nimport type { PlatformError } from \"effect/PlatformError\";\n\nimport { captured } from \"#/entities/decision/index.ts\";\n\nconst SELF = \"masseater/masseater.dev\";\nconst GIT_SUFFIX = /\\.git\\/?$/u;\nconst SEPARATORS = /[/:]/u;\nconst SLUG_PARTS = 2;\nconst GITDIR = /^gitdir:\\s*(?<dir>.+)$/mu;\nconst ORIGIN_URL = /\\[remote \"origin\"\\][^[]*?\\burl\\s*=\\s*(?<url>\\S+)/u;\n\nconst isSet = (name: string): Effect.Effect<boolean> =>\n Config.option(Config.NonEmptyString(name)).pipe(\n Effect.map(Option.isSome),\n Effect.orElseSucceed(() => false),\n );\n\nconst contextOf = Effect.gen(function* contextOf() {\n if (yield* isSet(\"GITHUB_ACTIONS\")) {\n return \"github-actions\";\n }\n if (yield* isSet(\"CLAUDE_CODE_REMOTE\")) {\n return \"claude-code-cloud\";\n }\n if (yield* isSet(\"CLAUDECODE\")) {\n return \"claude-code\";\n }\n return \"local\";\n});\n\nconst slugOf = (url: string): Option.Option<string> => {\n const parts = pipe(\n url,\n Str.trim,\n Str.replace(GIT_SUFFIX, \"\"),\n Str.split(SEPARATORS),\n Arr.filter((part) => Str.isNonEmpty(part)),\n );\n if (parts.length < SLUG_PARTS) {\n return Option.none();\n }\n return Option.some(pipe(Arr.takeRight(parts, SLUG_PARTS), Arr.join(\"/\")));\n};\n\nconst linkedGitDir = Effect.fn(\"linkedGitDir\")(function* linkedGitDir(dir: string, dotGit: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const text = yield* fs.readFileString(dotGit);\n return captured(Str.match(GITDIR)(text), \"dir\").pipe(\n Option.map((found) => path.resolve(dir, Str.trim(found))),\n );\n});\n\n/** @internal */\nexport type AppServices = FileSystem.FileSystem | Path.Path;\n\nconst gitDirAt = Effect.fn(\"gitDirAt\")(function* gitDirAt(dir: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const dotGit = path.join(dir, \".git\");\n const info = yield* fs.stat(dotGit).pipe(Effect.option);\n if (Option.isNone(info)) {\n return Option.none<string>();\n }\n if (info.value.type === \"Directory\") {\n return Option.some(dotGit);\n }\n return yield* linkedGitDir(dir, dotGit);\n});\n\nconst gitDirFrom = (\n dir: string,\n): Effect.Effect<Option.Option<string>, PlatformError, AppServices> =>\n Effect.gen(function* walk() {\n const path = yield* Path.Path;\n const here = yield* gitDirAt(dir);\n const parent = path.dirname(dir);\n if (Option.isSome(here) || parent === dir) {\n return here;\n }\n return yield* gitDirFrom(parent);\n });\n\nconst commonDirOf = Effect.fn(\"commonDirOf\")(function* commonDirOf(gitDir: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const common = yield* fs.readFileString(path.join(gitDir, \"commondir\")).pipe(Effect.option);\n return Option.match(common, {\n onNone: () => gitDir,\n onSome: (relative) => path.resolve(gitDir, Str.trim(relative)),\n });\n});\n\nconst remoteSlug = Effect.gen(function* remoteSlug() {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const gitDir = yield* gitDirFrom(path.resolve(\".\"));\n if (Option.isNone(gitDir)) {\n return Option.none<string>();\n }\n const commonDir = yield* commonDirOf(gitDir.value);\n const config = yield* fs.readFileString(path.join(commonDir, \"config\"));\n return captured(Str.match(ORIGIN_URL)(config), \"url\").pipe(Option.flatMap(slugOf));\n}).pipe(Effect.orElseSucceed(() => Option.none<string>()));\n\nconst repoOf = Effect.gen(function* repoOf() {\n const fromActions = yield* Config.option(Config.NonEmptyString(\"GITHUB_REPOSITORY\")).pipe(\n Effect.orElseSucceed(() => Option.none<string>()),\n );\n if (Option.isSome(fromActions)) {\n return fromActions;\n }\n return yield* remoteSlug;\n});\n\n/** @internal */\nexport interface AppContext {\n readonly repo: string;\n readonly context: string;\n}\n\n/** @internal */\nexport const appContext: Effect.Effect<AppContext, never, AppServices> = Effect.gen(\n function* app() {\n const context = yield* contextOf;\n const repo = yield* repoOf;\n return { repo: Option.getOrElse(repo, () => SELF), context };\n },\n);\n","import { Array as Arr, Effect, Option, Schedule, Schema, pipe } from \"effect\";\nimport type { Redacted } from \"effect\";\nimport { HttpClient, HttpClientRequest, HttpClientResponse } from \"effect/http\";\n\nimport { AnswerSchema } from \"#/entities/decision/index.ts\";\nimport type { DecisionResponse, WireRequest } from \"#/entities/decision/index.ts\";\n\nconst FIRST_REDIRECT = 300;\nconst RETRY_INITIAL_MS = 10;\nconst RETRY_EXPONENT = 2;\n\nconst Decisions = Schema.Struct({\n model: Schema.String,\n answers: Schema.Record(Schema.String, AnswerSchema),\n});\n\nconst Envelope = Schema.Struct({ result: Decisions });\n\nconst ErrorMessage = Schema.Struct({ message: Schema.String });\n\nconst ErrorBody = Schema.Union([\n Schema.Struct({ errors: Schema.NonEmptyArray(ErrorMessage) }),\n Schema.Struct({ detail: ErrorMessage }),\n]);\n\nconst decodeErrorBody = Schema.decodeUnknownOption(ErrorBody);\n\nconst messageOfBody = (body: unknown): string =>\n Option.match(decodeErrorBody(body), {\n onNone: () => \"request failed\",\n onSome: (decoded) => {\n if (\"detail\" in decoded) {\n return decoded.detail.message;\n }\n return pipe(\n decoded.errors,\n Arr.map(({ message }) => message),\n Arr.join(\"; \"),\n );\n },\n });\n\nconst failureOf = (response: HttpClientResponse.HttpClientResponse): Effect.Effect<never, string> =>\n response.json.pipe(\n Effect.option,\n Effect.flatMap((body) =>\n Effect.fail(`http ${String(response.status)}: ${messageOfBody(Option.getOrUndefined(body))}`),\n ),\n );\n\n/** @internal */\nexport interface SystemOneCall {\n readonly url: string;\n readonly model: string;\n readonly token: Redacted.Redacted;\n readonly headers: Readonly<Record<string, string>>;\n readonly envelope: boolean;\n}\n\nconst decodeEnvelope = HttpClientResponse.schemaBodyJson(Envelope);\n\nconst decodeDecisions = HttpClientResponse.schemaBodyJson(Decisions);\n\nconst invalid = ({ message }: Readonly<{ message: string }>): string =>\n `invalid response: ${message}`;\n\nconst decisionsOf = (\n response: HttpClientResponse.HttpClientResponse,\n envelope: boolean,\n): Effect.Effect<typeof Decisions.Type, string> => {\n if (envelope) {\n return decodeEnvelope(response).pipe(\n Effect.mapBoth({ onSuccess: ({ result }) => result, onFailure: invalid }),\n );\n }\n return decodeDecisions(response).pipe(Effect.mapError(invalid));\n};\n\n/** @internal */\nexport const sendSystemOne = Effect.fn(\"sendSystemOne\")(function* sendSystemOne(\n call: SystemOneCall,\n wire: WireRequest,\n) {\n const client = (yield* HttpClient.HttpClient).pipe(\n HttpClient.retryTransient({\n retryOn: \"response-only\",\n schedule: Schedule.exponential(RETRY_INITIAL_MS, RETRY_EXPONENT),\n }),\n );\n const response = yield* HttpClientRequest.post(call.url).pipe(\n HttpClientRequest.bearerToken(call.token),\n HttpClientRequest.setHeaders(call.headers),\n HttpClientRequest.bodyJsonUnsafe({\n model: call.model,\n state: wire.state,\n questions: wire.questions,\n }),\n client.execute,\n Effect.mapError(({ message }) => `network: ${message}`),\n );\n if (response.status >= FIRST_REDIRECT) {\n return yield* failureOf(response);\n }\n const decisions = yield* decisionsOf(response, call.envelope);\n return { model: decisions.model, answers: decisions.answers } satisfies DecisionResponse;\n});\n","import { Config, Effect, Option, String as Str } from \"effect\";\n\nimport { PREFIX, captured, envNameOf, toJson } from \"#/entities/decision/index.ts\";\nimport type { DecideInput, WireRequest } from \"#/entities/decision/index.ts\";\n\nimport { appContext } from \"./app-context.ts\";\nimport { sendSystemOne } from \"./system-one.ts\";\n\nconst DEFAULT_GATEWAY = \"default\";\nconst DEFAULT_API_URL = \"https://api.cloudflare.com/client/v4\";\nconst RUN_PATH = \"/ai/run\";\nconst TRAILING_SLASHES = /\\/+$/u;\nconst MODEL_NAME = /(?<name>[^/]+)$/u;\n\nconst accountUrl = ({ api, account }: Readonly<{ api: string; account: string }>): string =>\n `${Str.replace(TRAILING_SLASHES, \"\")(Str.trim(api))}/accounts/${Str.trim(account)}`;\n\n/** @internal */\nexport const endpointOf = (env: DecideInput[\"env\"]): Config.Config<string> =>\n Config.all({\n api: Config.String(envNameOf(env, \"CLOUDFLARE_API_BASE_URL\")).pipe(\n Config.withDefault(DEFAULT_API_URL),\n ),\n account: Config.NonEmptyString(envNameOf(env, \"CLOUDFLARE_ACCOUNT_ID\")),\n }).pipe(Config.map(accountUrl));\n\nconst modelNameOf = (model: string): string =>\n Option.getOrElse(captured(Str.match(MODEL_NAME)(model), \"name\"), () => model);\n\n/** @internal */\nexport const sendWorkersAi = Effect.fn(\"sendWorkersAi\")(function* sendWorkersAi(\n endpoint: string,\n wire: WireRequest,\n { env }: Pick<DecideInput, \"env\">,\n) {\n const token = yield* Config.Redacted(envNameOf(env, \"CLOUDFLARE_API_TOKEN\"));\n const gateway = yield* Config.NonEmptyString(envNameOf(env, \"CLOUDFLARE_AI_GATEWAY_ID\")).pipe(\n Config.withDefault(DEFAULT_GATEWAY),\n );\n const app = yield* appContext;\n const decided = yield* sendSystemOne(\n {\n url: `${endpoint}${RUN_PATH}/${wire.model}`,\n model: modelNameOf(wire.model),\n token,\n headers: {\n \"cf-aig-gateway-id\": gateway,\n \"cf-aig-metadata\": toJson({ tool: PREFIX, ...app }),\n },\n envelope: true,\n },\n wire,\n );\n return { model: wire.model, answers: decided.answers };\n});\n","import { Config, Effect, String as Str } from \"effect\";\n\nimport { envNameOf } from \"#/entities/decision/index.ts\";\nimport type { DecideInput, WireRequest } from \"#/entities/decision/index.ts\";\n\nimport { sendSystemOne } from \"./system-one.ts\";\n\nconst DEFAULT_BASE_URL = \"https://api.typesafe.ai\";\nconst SYSTEM_ONE_PATH = \"/v1/systemone\";\nconst TRAILING_SLASHES = /\\/+$/u;\n\n/** @internal */\nexport const typesafeEndpointOf = (env: DecideInput[\"env\"]): Config.Config<string> =>\n Config.String(envNameOf(env, \"TYPESAFE_BASE_URL\")).pipe(\n Config.withDefault(DEFAULT_BASE_URL),\n Config.map((url) => Str.replace(TRAILING_SLASHES, \"\")(Str.trim(url))),\n );\n\n/** @internal */\nexport const sendTypesafe = Effect.fn(\"sendTypesafe\")(function* sendTypesafe(\n endpoint: string,\n wire: WireRequest,\n { env }: Pick<DecideInput, \"env\">,\n) {\n const token = yield* Config.Redacted(envNameOf(env, \"TYPESAFE_API_KEY\"));\n return yield* sendSystemOne(\n {\n url: `${endpoint}${SYSTEM_ONE_PATH}`,\n model: wire.model,\n token,\n headers: {},\n envelope: false,\n },\n wire,\n );\n});\n","import { Clock, Effect, FileSystem, Option, Path, Schema, Function as Fn } from \"effect\";\nimport { Digest } from \"effect/crypto\";\n\nimport { AnswerSchema, PREFIX, parseVerdicts } from \"#/entities/decision/index.ts\";\nimport type { DecisionRequest, DecisionResponse } from \"#/entities/decision/index.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nconst CACHE_VERSION = 7;\n/** @internal */\nexport const CACHE_DIR = `node_modules/.cache/${PREFIX}`;\n\nconst encodeJson = (value: unknown): Effect.Effect<string> =>\n Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(value).pipe(Effect.orDie);\n\n/** @internal */\nexport const cacheFile = Effect.fn(\"cacheFile\")(function* cacheFile(\n endpoint: string,\n request: DecisionRequest,\n) {\n const digest = yield* Digest.Digest;\n const path = yield* Path.Path;\n const json = yield* encodeJson({ version: CACHE_VERSION, endpoint, request });\n const payload = new TextEncoder().encode(json);\n const hash = yield* digest.digestHex(Digest.sha256, payload);\n return path.resolve(CACHE_DIR, `${hash}.json`);\n});\n\nconst CachedResponse = Schema.Struct({\n model: Schema.NonEmptyString,\n answers: Schema.Record(Schema.String, AnswerSchema),\n});\n\nconst decodeCached = Schema.decodeOption(Schema.fromJsonString(CachedResponse));\n\n/** @internal */\nexport const isComplete: {\n (request: DecisionRequest): (response: DecisionResponse) => boolean;\n (response: DecisionResponse, request: DecisionRequest): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (response: DecisionResponse, request: DecisionRequest): boolean =>\n Option.liftThrowable(() => parseVerdicts(response, request).complete)().pipe(\n Option.getOrElse(() => false),\n ),\n);\n\n/** @internal */\nexport const readCache = Effect.fn(\"readCache\")(function* readCache(\n file: string,\n request: DecisionRequest,\n) {\n const fs = yield* FileSystem.FileSystem;\n const text = yield* fs.readFileString(file).pipe(Effect.option);\n return text.pipe(\n Option.flatMap((raw): Option.Option<DecisionResponse> => decodeCached(raw)),\n Option.filter((response) => isComplete(response, request)),\n );\n});\n\n/** @internal */\nexport const writeCache = Effect.fn(\"writeCache\")(function* writeCache(\n file: string,\n response: DecisionResponse,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const now = yield* Clock.currentTimeMillis;\n const temp = `${file}.tmp-${String(now)}`;\n const json = yield* encodeJson(response);\n yield* fs.makeDirectory(path.dirname(file), { recursive: true });\n yield* fs.writeFileString(temp, json);\n yield* fs.rename(temp, file);\n});\n\n/** @internal */\nexport type CacheServices = Digest.Digest | FileSystem.FileSystem | Path.Path;\n","import { layerDigest } from \"@effect/platform-node-shared/NodeCrypto\";\nimport { layer as fileSystem } from \"@effect/platform-node-shared/NodeFileSystem\";\nimport { layer as path } from \"@effect/platform-node-shared/NodePath\";\nimport { Layer } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { OtlpSerialization, OtlpTracer } from \"effect/observability\";\n\nconst tracing = OtlpTracer.layerFromConfig({\n resource: { serviceName: \"oxlint-plugin-decision\" },\n}).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));\n\n/** @internal */\nexport const workerServices: [\n typeof fileSystem,\n typeof path,\n typeof layerDigest,\n typeof FetchHttpClient.layer,\n typeof tracing,\n] = [fileSystem, path, layerDigest, FetchHttpClient.layer, tracing];\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\nimport type { Config } from \"effect\";\nimport type { HttpClient } from \"effect/http\";\nimport { runAsWorker } from \"synckit\";\n\nimport { mergeResponses, messageOf } from \"#/entities/decision/index.ts\";\nimport type {\n DecideInput,\n DecideResult,\n DecisionRequest,\n DecisionResponse,\n WireRequest,\n} from \"#/entities/decision/index.ts\";\n\nimport type { AppServices } from \"./app-context.ts\";\nimport { cacheFile, isComplete, readCache, writeCache } from \"./cache.ts\";\nimport type { CacheServices } from \"./cache.ts\";\nimport { workerServices } from \"./services.ts\";\n\n/** @internal */\nexport type Services = AppServices | CacheServices | HttpClient.HttpClient;\n\ntype Inputs = Arr.NonEmptyReadonlyArray<DecideInput>;\n\n/** @internal */\nexport interface Transport {\n readonly endpoint: (env: DecideInput[\"env\"]) => Config.Config<string>;\n readonly wires: (request: DecisionRequest) => Arr.NonEmptyReadonlyArray<WireRequest>;\n readonly send: (\n endpoint: string,\n wire: WireRequest,\n input: Pick<DecideInput, \"env\">,\n ) => Effect.Effect<DecisionResponse, Config.ConfigError | string, Services>;\n}\n\nconst ask = Effect.fn(\"ask\")(function* ask(\n transport: Transport,\n endpoint: string,\n { request, timeoutMs, env }: DecideInput,\n) {\n const responses = yield* Effect.forEach(\n transport.wires(request),\n (wire) => transport.send(endpoint, wire, { env }),\n { concurrency: \"unbounded\" },\n ).pipe(\n Effect.timeoutOrElse({\n duration: timeoutMs,\n orElse: () => Effect.fail(\"timeout\"),\n }),\n );\n return mergeResponses(responses);\n});\n\nconst askAndStore = Effect.fn(\"askAndStore\")(function* askAndStore(\n transport: Transport,\n { endpoint, file }: Readonly<{ endpoint: string; file: string }>,\n input: DecideInput,\n) {\n const response = yield* ask(transport, endpoint, input);\n if (isComplete(response, input.request)) {\n yield* writeCache(file, response).pipe(Effect.ignore);\n }\n return response;\n});\n\nconst decide = Effect.fn(\"decide\")(function* decide(transport: Transport, input: DecideInput) {\n yield* Effect.annotateCurrentSpan({ model: input.request.model });\n const endpoint = yield* transport.endpoint(input.env);\n const file = yield* cacheFile(endpoint, input.request);\n const cached = yield* readCache(file, input.request);\n yield* Effect.annotateCurrentSpan({ cached: Option.isSome(cached) });\n if (Option.isSome(cached)) {\n return { response: cached.value, cached: true };\n }\n return { response: yield* askAndStore(transport, { endpoint, file }, input), cached: false };\n});\n\nconst reasonOf = (error: unknown): string => {\n if (typeof error === \"string\") {\n return error;\n }\n return messageOf(error);\n};\n\nconst decideOne = (\n transport: Transport,\n input: DecideInput,\n): Effect.Effect<DecideResult, never, Services> =>\n decide(transport, input).pipe(\n Effect.match({\n onSuccess: ({ response, cached }): DecideResult => ({ ok: true, response, cached }),\n onFailure: (error): DecideResult => ({ ok: false, reason: reasonOf(error) }),\n }),\n );\n\nconst decideEach = (\n transport: Transport,\n inputs: Inputs,\n): Effect.Effect<Arr.NonEmptyReadonlyArray<DecideResult>> =>\n Effect.all(\n pipe(\n inputs,\n Arr.map((input) => decideOne(transport, input)),\n ),\n { concurrency: \"unbounded\" },\n ).pipe(Effect.provide(workerServices));\n\n/** @internal */\nexport const serveDecisions = (transport: Transport): void => {\n runAsWorker((inputs: Inputs): Promise<Arr.NonEmptyReadonlyArray<DecideResult>> =>\n Effect.runPromise(decideEach(transport, inputs)),\n );\n};\n"],"mappings":";;;;;;;;;;AAcA,MAAM,OAA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OAAO,IACL,KACE,QACAC,MAAI,KAAK,UAAU,UAAU,WAAW,KAAK,CAAC,CAChD,GACA,EAAE,aAAa,YAAY,CAC7B,CAAC,CAAC,KAAK,OAAO,QAAQ,cAAc,CAAC;;AAGvC,MAAa,kBAAkB,cAA+B;CAC5D,aAAa,WACX,OAAO,WAAW,WAAW,WAAW,MAAM,CAAC,CACjD;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as fileRequestsFor } from "./decision-B7hahWHz.mjs";
|
|
2
|
+
import { n as sendTypesafe, r as typesafeEndpointOf, t as serveDecisions } from "./serve-decisions-DYGwLMft.mjs";
|
|
3
|
+
// src/app/typesafe-worker.ts
|
|
4
|
+
serveDecisions({
|
|
5
|
+
endpoint: typesafeEndpointOf,
|
|
6
|
+
wires: fileRequestsFor,
|
|
7
|
+
send: sendTypesafe
|
|
8
|
+
});
|
|
9
|
+
export {};
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=typesafe-worker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typesafe-worker.mjs","names":[],"sources":["../src/app/typesafe-worker.ts"],"sourcesContent":["import { fileRequestsFor } from \"#/entities/decision/index.ts\";\nimport {\n sendTypesafe,\n serveDecisions,\n typesafeEndpointOf,\n} from \"#/features/serve-decisions/index.ts\";\n\nserveDecisions({\n endpoint: typesafeEndpointOf,\n wires: fileRequestsFor,\n send: sendTypesafe,\n});\n"],"mappings":";;;AAOA,eAAe;CACb,UAAU;CACV,OAAO;CACP,MAAM;AACR,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/oxlint-plugin-decision",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Oxlint JS plugin that lints code with plain-English rules answered by decision models: Clef on Workers AI or Jev on
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Oxlint JS plugin that lints code with plain-English rules answered by decision models: Clef on Workers AI or Jev on the Typesafe System One API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-gateway",
|
|
7
7
|
"cloudflare",
|
|
8
8
|
"decision-model",
|
|
9
9
|
"lint",
|
|
10
|
-
"openrouter",
|
|
11
10
|
"oxlint",
|
|
12
11
|
"oxlint-plugin",
|
|
13
12
|
"preset",
|
|
14
|
-
"tanstack-intent"
|
|
13
|
+
"tanstack-intent",
|
|
14
|
+
"typesafe"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://github.com/masseater/masseater.dev/tree/main/libs/oxlint-plugin-decision#readme",
|
|
17
17
|
"bugs": {
|
|
@@ -37,10 +37,6 @@
|
|
|
37
37
|
"types": "./dist/index.d.mts",
|
|
38
38
|
"default": "./dist/index.mjs"
|
|
39
39
|
},
|
|
40
|
-
"./openrouter-app": {
|
|
41
|
-
"types": "./dist/openrouter-app.d.mts",
|
|
42
|
-
"default": "./dist/openrouter-app.mjs"
|
|
43
|
-
},
|
|
44
40
|
"./presets": {
|
|
45
41
|
"types": "./dist/presets/index.d.mts",
|
|
46
42
|
"default": "./dist/presets/index.mjs"
|
|
@@ -68,13 +64,12 @@
|
|
|
68
64
|
"provenance": true
|
|
69
65
|
},
|
|
70
66
|
"dependencies": {
|
|
71
|
-
"@effect/ai-openrouter": "4.1.4",
|
|
72
67
|
"synckit": "0.12.3"
|
|
73
68
|
},
|
|
74
69
|
"devDependencies": {
|
|
75
70
|
"@effect/platform-node": "4.1.4",
|
|
76
71
|
"@effect/platform-node-shared": "4.1.4",
|
|
77
|
-
"@effect/tsgo": "0.
|
|
72
|
+
"@effect/tsgo": "0.69.0",
|
|
78
73
|
"@effect/vitest": "4.1.4",
|
|
79
74
|
"@oxlint/plugins": "1.93.0",
|
|
80
75
|
"@types/node": "26.6.6",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: write-decision-rules
|
|
3
3
|
description: >
|
|
4
4
|
Use when writing, wiring up, or debugging lint rules for @r_masseater/oxlint-plugin-decision: rules
|
|
5
|
-
phrased as plain-English questions that decision models on Workers AI or
|
|
5
|
+
phrased as plain-English questions that decision models on Workers AI or the Typesafe API answer about functions, calls,
|
|
6
6
|
JSX elements, or whole files in an Oxlint run. Covers defineDecisionRule, createDecisionPlugin,
|
|
7
7
|
enabling the rules in oxlint.config.ts, select, answer kinds, context, per-rule models, settings,
|
|
8
8
|
explain mode, and keeping request cost under control. Also use when someone wants a lint check
|
|
@@ -38,7 +38,7 @@ The package root ships no rules; the ready-made ones are under `/presets`. You w
|
|
|
38
38
|
export CLOUDFLARE_API_TOKEN="..." # account API token with Workers AI Read
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Result: `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` are set in the shell that runs oxlint. The default model, `cloudflare/@cf/cloudflare/clef-flash`, runs on Workers AI. `
|
|
41
|
+
Result: `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` are set in the shell that runs oxlint. The default model, `cloudflare/@cf/cloudflare/clef-flash`, runs on Workers AI. `typesafe/jev-...` models read `TYPESAFE_API_KEY` instead. Without it the plugin warns once and reports nothing outside CI, and fails the run in CI.
|
|
42
42
|
|
|
43
43
|
2. Write a plugin file that default-exports `createDecisionPlugin`.
|
|
44
44
|
|
|
@@ -167,18 +167,18 @@ Settings apply to the whole plugin. Pass them to `createDecisionPlugin` or put t
|
|
|
167
167
|
|
|
168
168
|
| Setting | Default | Meaning |
|
|
169
169
|
| ----------------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
170
|
-
| `model` | `"cloudflare/@cf/cloudflare/clef-flash"` |
|
|
170
|
+
| `model` | `"cloudflare/@cf/cloudflare/clef-flash"` | A decision model id (Clef or Jev), or a list; every listed model answers every match. |
|
|
171
171
|
| `ci` | `"fail"` | When `CI` is set and a model can't be asked: `"fail"` fails the run, `"skip"` warns. A spent budget only warns. |
|
|
172
172
|
| `timeoutMs` | `10000` | Per-file budget shared by every request, retry, and location refinement. |
|
|
173
173
|
| `maxSnippetChars` | `4000` | Longer snippets are cut and end with `/* ...truncated */`. |
|
|
174
174
|
| `env` | `{}` | Renames variables providers read, e.g. `{ CLOUDFLARE_API_TOKEN: "TEAM_KEY" }`. Names only. |
|
|
175
175
|
| `explain` | `false` | `true`/`"text"` or `"json"` prints why each match was or wasn't reported, to stderr. |
|
|
176
176
|
|
|
177
|
-
A rule's model comes from the first source that sets one. The rule's options in `oxlint.config.ts` come first, such as `["warn", { model: "
|
|
177
|
+
A rule's model comes from the first source that sets one. The rule's options in `oxlint.config.ts` come first, such as `["warn", { model: "typesafe/jev-latest" }]`. Next comes the rule's own `model`, and then `settings.<plugin name>.model`. After that comes the `model` passed to `createDecisionPlugin`. The default comes last.
|
|
178
178
|
|
|
179
179
|
When tuning a question or cutoff, or switching models, read [tuning rules](references/tuning.md) first.
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
The plugin asks only Clef and Jev. Other models and custom providers are refused.
|
|
182
182
|
|
|
183
183
|
## Common Mistakes
|
|
184
184
|
|
|
@@ -231,6 +231,6 @@ Asking whether a function is named well reports the well-named functions. With t
|
|
|
231
231
|
|
|
232
232
|
## Completion
|
|
233
233
|
|
|
234
|
-
1. Run `npx oxlint` (or the CI overlay) on a file that should fail and one that should pass. Result: the failing file gets a diagnostic like `[no-pii-in-logs]
|
|
234
|
+
1. Run `npx oxlint` (or the CI overlay) on a file that should fail and one that should pass. Result: the failing file gets a diagnostic like `[no-pii-in-logs] cloudflare/... answered yes (0.93 >= 0.80): ...`. The passing file gets none.
|
|
235
235
|
2. If nothing is reported, run once with `OXLINT_DECISION_EXPLAIN=1` and check stderr. A missing match means the target, `select` or `context: { scope: "comment" }` excluded it. An `error` line means the key, timeout or API failed. A low probability means the question or cutoff needs tuning (see [tuning rules](references/tuning.md)).
|
|
236
236
|
3. If the plugin fails to load, fix the rule or setting the thrown error names; do not remove validation.
|
|
@@ -21,9 +21,7 @@ A changed question, snippet, context, or answer kind re-asks that file. A change
|
|
|
21
21
|
|
|
22
22
|
Probabilities are not calibrated the same across models. Re-tune cutoffs after switching, and pin a versioned model id once tuned.
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
You can override one rule's model in `oxlint.config.ts` without touching the plugin file. For example, write `"team/stale-comment": ["warn", { model: "openrouter/~typesafe/jev-latest" }]`. Rules on different models are asked in separate requests and cached separately.
|
|
24
|
+
You can override one rule's model in `oxlint.config.ts` without touching the plugin file. For example, write `"team/stale-comment": ["warn", { model: "typesafe/jev-latest" }]`. Rules on different models are asked in separate requests and cached separately.
|
|
27
25
|
|
|
28
26
|
## Cache
|
|
29
27
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-Bso1uwY5.mjs","names":["Str","Arr","DATA_FIRST_ARITY_3","Fn","Arr","DECIMALS","Bool","Arr","Rec","Bool","Str","Arr","Rec","Fn","DATA_FIRST_ARITY","Fn","Arr","Bool","Rec","Arr","Rec","Fn","Rec","Arr"],"sources":["../src/entities/decision/model/budget.ts","../src/entities/decision/model/define.ts","../src/app/sync-provider.ts","../src/app/cloudflare.ts","../src/app/openrouter.ts","../src/features/judge-code/model/override.ts","../src/features/judge-code/model/explain-text.ts","../src/features/judge-code/model/explain.ts","../src/features/judge-code/model/locate.ts","../src/features/judge-code/model/report.ts","../src/features/judge-code/model/visitor.ts","../src/app/plugin.ts"],"sourcesContent":["export const OUT_OF_BUDGET = /^http (?:402|403): .*(?:credit|budget)/iu;\n","import type { DecisionProvider, DecisionRule } from \"./types.ts\";\n\nexport const defineDecisionRule = <const Rule extends DecisionRule>(rule: Rule): Rule => rule;\n\nexport const defineProvider = <const Provider extends DecisionProvider>(\n provider: Provider,\n): Provider => provider;\n","import { Array as Arr, Effect, Option, Predicate, String as Str, pipe } from \"effect\";\nimport { createSyncFn } from \"synckit\";\nimport type { Syncify } from \"synckit\";\n\nimport { messageOf, runOrElse } from \"#/entities/decision/index.ts\";\nimport type { DecideInput, DecideResult, DecisionProvider } from \"#/entities/decision/index.ts\";\n\nconst BACKSTOP_MS = 60_000;\nconst SYNCKIT_TIMEOUT = \"Internal error: Atomics.wait() failed: timed-out\";\nconst BUILT_EXTENSION = \".mjs\";\nconst MODULE_EXTENSION = /\\.[cm]?[jt]s$/u;\n\ntype Inputs = Arr.NonEmptyReadonlyArray<DecideInput>;\n\ntype Results = Arr.NonEmptyReadonlyArray<DecideResult>;\n\ntype Worker = (inputs: Inputs) => Promise<Results>;\n\n/** @internal */\nexport interface SyncProviderSetup extends Pick<\n DecisionProvider,\n \"name\" | \"requiredEnv\" | \"models\" | \"yesNo\"\n> {\n readonly worker: string;\n}\n\nconst workers = new Map<string, Syncify<Worker>>();\n\nconst workerUrl = (worker: string): URL => {\n const extension = pipe(\n Str.match(MODULE_EXTENSION)(import.meta.url),\n Option.flatMap(Arr.head),\n Option.getOrElse(() => BUILT_EXTENSION),\n );\n return new URL(`${worker}${extension}`, import.meta.url);\n};\n\nconst workerCall = (worker: string): Syncify<Worker> => {\n const existing = workers.get(worker);\n if (Predicate.isNotUndefined(existing)) {\n return existing;\n }\n const created = createSyncFn<Worker>(workerUrl(worker), { timeout: BACKSTOP_MS });\n workers.set(worker, created);\n return created;\n};\n\nconst reasonOf = (error: unknown): string => {\n const message = messageOf(error);\n if (message === SYNCKIT_TIMEOUT) {\n return \"timeout\";\n }\n return `network: ${message}`;\n};\n\nconst askWorker = (worker: string, inputs: Inputs): Results =>\n runOrElse(\n Effect.sync(() => workerCall(worker)(inputs)),\n (cause) =>\n pipe(\n inputs,\n Arr.map((): DecideResult => ({ ok: false, reason: reasonOf(cause) })),\n ),\n );\n\n/** @internal */\nexport const syncProvider = ({ worker, ...provider }: SyncProviderSetup): DecisionProvider => ({\n ...provider,\n decide: (input) => Arr.headNonEmpty(askWorker(worker, [input])),\n decideAll: (inputs) =>\n Arr.match(inputs, { onEmpty: () => [], onNonEmpty: (some) => askWorker(worker, some) }),\n});\n","import { syncProvider } from \"./sync-provider.ts\";\n\nexport const cloudflare = syncProvider({\n name: \"cloudflare\",\n worker: \"cloudflare-worker\",\n requiredEnv: [\"CLOUDFLARE_API_TOKEN\", \"CLOUDFLARE_ACCOUNT_ID\"],\n models: /^@cf\\/cloudflare\\/clef(?:-[a-z]+)?$/u,\n});\n","import { syncProvider } from \"./sync-provider.ts\";\n\nexport const openRouter = syncProvider({\n name: \"openrouter\",\n worker: \"openrouter-worker\",\n requiredEnv: [\"OPENROUTER_API_KEY\"],\n});\n","import type { RuleOptionsSchema } from \"@oxlint/plugins\";\nimport { Option, Predicate, Schema, Array as Arr, pipe, Function as Fn } from \"effect\";\n\nimport {\n ModelSpecSchema,\n STRICT,\n checked,\n modelIdsOf,\n resolveModel,\n} from \"#/entities/decision/index.ts\";\nimport type { DecisionProvider, ResolvedRule } from \"#/entities/decision/index.ts\";\n\nconst DATA_FIRST_ARITY_3 = 3;\n\nconst RuleOverrideSchema = Schema.Struct({\n model: Schema.optionalKey(ModelSpecSchema),\n});\n\nexport const RULE_OPTIONS_SCHEMA = [\n {\n type: \"object\",\n additionalProperties: false,\n properties: {\n model: {\n oneOf: [\n { type: \"string\", minLength: 1 },\n { type: \"array\", minItems: 1, items: { type: \"string\", minLength: 1 } },\n ],\n },\n },\n },\n] satisfies RuleOptionsSchema;\n\nconst decodeOverride = Schema.decodeUnknownResult(RuleOverrideSchema, STRICT);\n\nexport const overrideRule: {\n (\n raw: unknown,\n providers: Readonly<Record<string, DecisionProvider>>,\n ): (rule: ResolvedRule) => ResolvedRule;\n (\n rule: ResolvedRule,\n raw: unknown,\n providers: Readonly<Record<string, DecisionProvider>>,\n ): ResolvedRule;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (\n rule: ResolvedRule,\n raw: unknown,\n providers: Readonly<Record<string, DecisionProvider>>,\n ): ResolvedRule => {\n if (Predicate.isUndefined(raw)) {\n return rule;\n }\n const { model } = checked(decodeOverride, raw, `options for rule \"${rule.id}\"`);\n return {\n ...rule,\n models: Option.match(Option.fromUndefinedOr(model), {\n onNone: () => rule.models,\n onSome: (spec) =>\n pipe(\n modelIdsOf(spec),\n Arr.map((id) => resolveModel(id, providers)),\n ),\n }),\n };\n },\n);\n","import { Array as Arr, Boolean as Bool, Option, Predicate, Record as Rec, pipe } from \"effect\";\n\nimport { PREFIX, toJson } from \"#/entities/decision/index.ts\";\nimport type { Verdict } from \"#/entities/decision/index.ts\";\n\nconst DECIMALS = 2;\nexport interface ExplainQuestion {\n readonly id: string;\n readonly question: string;\n readonly probabilities: Readonly<Record<string, number>>;\n}\n\nexport interface Explanation {\n readonly file: string;\n readonly line: number;\n readonly column: number;\n readonly rule: string;\n readonly model: string;\n readonly served?: string;\n readonly cutoff: number;\n readonly cached?: boolean;\n readonly durationMs: number;\n readonly state: { readonly chars: number; readonly head: string };\n readonly questions: readonly ExplainQuestion[];\n readonly verdict?: Verdict;\n readonly reported: boolean;\n readonly error?: string;\n}\nconst fixed = (value: number): string => value.toFixed(DECIMALS);\n\nconst cachedText = (cached: boolean | undefined): string =>\n Option.match(Option.fromUndefinedOr(cached), {\n onNone: () => \"unknown\",\n onSome: (hit) => Bool.match(hit, { onTrue: () => \"yes\", onFalse: () => \"no\" }),\n });\n\nconst probabilitiesText = (probabilities: Readonly<Record<string, number>>): string =>\n Option.match(\n Arr.match(Rec.toEntries(probabilities), {\n onEmpty: () => Option.none<string>(),\n onNonEmpty: (entries) =>\n Option.some(\n pipe(\n entries,\n Arr.map(([label, value]) => `${label}=${fixed(value)}`),\n Arr.join(\" \"),\n ),\n ),\n }),\n { onNone: () => \"(no answer)\", onSome: (text) => text },\n );\n\nconst verdictText = (explanation: Explanation): string => {\n if (Predicate.isNotUndefined(explanation.error)) {\n return `error: ${explanation.error}`;\n }\n const outcome = Bool.match(explanation.reported, {\n onTrue: () => \"reported\",\n onFalse: () => \"not reported\",\n });\n const cutoff = `cutoff ${fixed(explanation.cutoff)}`;\n return Option.match(Option.fromUndefinedOr(explanation.verdict), {\n onNone: () => `no verdict, ${cutoff}, ${outcome}`,\n onSome: ({ answer, probability }) => `${answer} ${fixed(probability)}, ${cutoff}, ${outcome}`,\n });\n};\n\nconst servedText = (served: string | undefined): string =>\n Option.match(Option.fromUndefinedOr(served), {\n onNone: () => \"\",\n onSome: (id) => ` (served ${id})`,\n });\n\nexport const asText = (explanation: Explanation): string =>\n pipe(\n [\n `${PREFIX} explain: ${explanation.file}:${String(explanation.line)}:${String(explanation.column)} [${explanation.rule}] ${explanation.model}${servedText(explanation.served)} cached=${cachedText(explanation.cached)} ${String(explanation.durationMs)}ms`,\n ` state: ${String(explanation.state.chars)} chars ${toJson(explanation.state.head)}`,\n ...pipe(\n explanation.questions,\n Arr.map(\n ({ id, question, probabilities }) =>\n ` ${id}: ${probabilitiesText(probabilities)}\\n ${question}`,\n ),\n ),\n ` verdict: ${verdictText(explanation)}`,\n ],\n Arr.join(\"\\n\"),\n );\n","import type { Location } from \"@oxlint/plugins\";\nimport {\n Array as Arr,\n Boolean as Bool,\n Console,\n Effect,\n Function as Fn,\n Match,\n Option,\n Predicate,\n String as Str,\n Record as Rec,\n pipe,\n} from \"effect\";\n\nimport {\n refAt,\n envOf,\n toJson,\n wireRequestsFor,\n yesNoRequestsFor,\n} from \"#/entities/decision/index.ts\";\nimport type {\n Answer,\n Answers,\n DecisionRequest,\n ExplainSetting,\n Match as RuleMatch,\n Question,\n Verdict,\n WireRequest,\n} from \"#/entities/decision/index.ts\";\n\nimport { asText } from \"./explain-text.ts\";\nimport type { Explanation } from \"./explain-text.ts\";\n\ntype ExplainFormat = Extract<ExplainSetting, string>;\n\ntype ExplainMode = \"off\" | ExplainFormat;\n\nconst EXPLAIN_ENV = \"OXLINT_DECISION_EXPLAIN\";\nconst OFF_VALUES: ReadonlySet<string> = new Set([\"0\", \"false\", \"off\", \"no\"]);\nconst STATE_HEAD_CHARS = 60;\nconst OPTION_SEPARATOR = \"__\";\nconst FIRST = 1;\nconst START = 0;\nconst COLUMN_BASE = 1;\n\nexport interface Outcome {\n readonly served: string;\n readonly answers: Answers;\n readonly cached: boolean | undefined;\n readonly verdict: Option.Option<Verdict>;\n readonly reported: boolean;\n}\n\nexport interface Explainer {\n readonly outcome: (match: RuleMatch, at: Placed, outcome: Outcome) => void;\n readonly failure: (matches: readonly RuleMatch[], reason: string) => void;\n}\n\nexport interface Placed {\n readonly ref: string;\n readonly loc: Location;\n}\n\nexport interface ExplainPass {\n readonly setting: ExplainSetting;\n readonly cwd: string;\n readonly filename: string;\n readonly model: string;\n readonly yesNo: boolean;\n readonly request: DecisionRequest;\n readonly durationMs: number;\n}\n\nconst SEPARATOR = /^[/\\\\]/u;\n\nconst relativeTo = (root: string, filename: string): string =>\n Bool.match(\n Str.isNonEmpty(root) &&\n Str.startsWith(root)(filename) &&\n SEPARATOR.test(Str.slice(root.length)(filename)),\n {\n onTrue: () => Str.slice(root.length + FIRST)(filename),\n onFalse: () => filename,\n },\n );\n\nconst fromSetting = (setting: ExplainSetting): ExplainMode =>\n Match.value(setting).pipe(\n Match.when(\"json\", (): ExplainMode => \"json\"),\n Match.when(true, (): ExplainMode => \"text\"),\n Match.when(\"text\", (): ExplainMode => \"text\"),\n Match.orElse((): ExplainMode => \"off\"),\n );\n\nconst fromEnv = (value: string): ExplainMode =>\n Match.value(Str.toLowerCase(value)).pipe(\n Match.when(\"json\", (): ExplainMode => \"json\"),\n Match.when(\n (lower) => OFF_VALUES.has(lower),\n (): ExplainMode => \"off\",\n ),\n Match.orElse((): ExplainMode => \"text\"),\n );\n\nconst explainModeOf = (setting: ExplainSetting): ExplainMode =>\n Option.match(envOf(EXPLAIN_ENV), { onNone: () => fromSetting(setting), onSome: fromEnv });\n\nconst probabilitiesIn = (answer: Answer): Option.Option<Readonly<Record<string, number>>> => {\n if (answer.type === \"noul\") {\n return Option.some({ yes: answer.noul });\n }\n if (answer.type === \"choice\") {\n return Option.fromUndefinedOr(answer.probabilities);\n }\n return Option.none();\n};\n\nconst probabilitiesOf = (answer: Answer | undefined): Readonly<Record<string, number>> =>\n Option.fromUndefinedOr(answer).pipe(\n Option.flatMap(probabilitiesIn),\n Option.getOrElse(() => ({})),\n );\n\nconst asksAbout = (ref: string, id: string): boolean =>\n pipe(Str.split(id, OPTION_SEPARATOR), Arr.take(FIRST), Arr.contains(ref));\n\nconst sentFor = (\n sent: readonly WireRequest[],\n ref: string,\n): readonly (readonly [string, Question])[] =>\n pipe(\n sent,\n Arr.flatMap((wire) =>\n pipe(\n Rec.toEntries(wire.questions),\n Arr.filter(([id]) => asksAbout(ref, id)),\n ),\n ),\n );\n\nconst stateTextOf = (sent: readonly WireRequest[], ref: string, snippet: string): string =>\n Arr.findFirst(sent, (wire) =>\n pipe(\n Rec.keys(wire.questions),\n Arr.some((id) => asksAbout(ref, id)),\n ),\n ).pipe(\n Option.map(({ state }) => state),\n Option.filter(Predicate.isString),\n Option.getOrElse(() => snippet),\n );\n\nconst summaryOf = (text: string): Explanation[\"state\"] => ({\n chars: text.length,\n head: Str.slice(START, STATE_HEAD_CHARS)(Str.trim(Str.replaceAll(/\\s+/gu, \" \")(text))),\n});\n\ntype Base = Pick<\n Explanation,\n \"file\" | \"line\" | \"column\" | \"rule\" | \"model\" | \"cutoff\" | \"durationMs\" | \"state\" | \"questions\"\n>;\n\ninterface Sent {\n readonly pass: ExplainPass;\n readonly sent: readonly WireRequest[];\n}\n\nconst baseOf = (\n { pass, sent }: Sent,\n match: RuleMatch,\n { ref, loc }: Placed,\n): ((answers: Answers) => Base) => {\n const questions = sentFor(sent, ref);\n return (answers) => ({\n file: relativeTo(pass.cwd, pass.filename),\n line: loc.start.line,\n column: loc.start.column + COLUMN_BASE,\n rule: match.rule.id,\n model: pass.model,\n cutoff: match.rule.cutoff,\n durationMs: pass.durationMs,\n state: summaryOf(stateTextOf(sent, ref, match.snippet)),\n questions: pipe(\n questions,\n Arr.map(([id, question]) => ({\n id,\n question: question.instructions,\n probabilities: probabilitiesOf(answers[id]),\n })),\n ),\n });\n};\n\nconst printerFor =\n (mode: ExplainFormat) =>\n (explanation: Explanation): void => {\n const line = Bool.match(mode === \"json\", {\n onTrue: () => toJson(explanation),\n onFalse: () => asText(explanation),\n });\n Effect.runFork(Console.error(line));\n };\n\nconst explaining = (pass: ExplainPass, mode: ExplainFormat): Explainer => {\n const sent = Bool.match(pass.yesNo, {\n onTrue: () => yesNoRequestsFor(pass.request),\n onFalse: () => wireRequestsFor(pass.request),\n });\n const print = printerFor(mode);\n return {\n outcome: (match, at, { served, answers, cached, verdict, reported }) => {\n print({\n ...baseOf({ pass, sent }, match, at)(answers),\n served,\n ...Option.match(Option.fromUndefinedOr(cached), {\n onNone: () => ({}),\n onSome: (hit) => ({ cached: hit }),\n }),\n ...Option.match(verdict, { onNone: () => ({}), onSome: (found) => ({ verdict: found }) }),\n reported,\n });\n },\n failure: (matches, reason) => {\n for (const [index, match] of matches.entries()) {\n const at = { ref: refAt(index), loc: match.loc };\n print({ ...baseOf({ pass, sent }, match, at)({}), reported: false, error: reason });\n }\n },\n };\n};\n\nconst SILENT: Explainer = { outcome: Fn.constVoid, failure: Fn.constVoid };\n\nexport const explainerFor = (pass: ExplainPass): Explainer =>\n Match.value(explainModeOf(pass.setting)).pipe(\n Match.when(\"off\", () => SILENT),\n Match.orElse((mode) => explaining(pass, mode)),\n );\n","import type { Location } from \"@oxlint/plugins\";\nimport { Effect, Option, Function as Fn } from \"effect\";\n\nimport {\n EVERY_LINE,\n locates,\n locationCandidates,\n locationOfLine,\n locationQuestion,\n selectedLocation,\n locationRefOf,\n parseVerdicts,\n messageOf,\n nowMs,\n runOrElse,\n} from \"#/entities/decision/index.ts\";\nimport type {\n LocatedMatch,\n DecideInput,\n DecideResult,\n DecisionRequest,\n LineRange,\n Match,\n ModelRef,\n Verdicts,\n} from \"#/entities/decision/index.ts\";\n\nconst DATA_FIRST_ARITY_3 = 3;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport type VerdictResult =\n | { readonly ok: true; readonly verdicts: Verdicts; readonly cached: boolean | undefined }\n | { readonly ok: false; readonly reason: string };\n\nexport interface Located {\n readonly loc: Location;\n readonly failure: Option.Option<string>;\n}\n\nexport interface Asking {\n readonly model: ModelRef;\n readonly deadline: number;\n readonly env: Readonly<Record<string, string>>;\n}\n\ninterface Refinement {\n readonly asking: Asking;\n readonly match: Match & LocatedMatch;\n readonly ref: string;\n readonly state: DecisionRequest[\"state\"];\n}\n\nconst MINIMUM_TIMEOUT_MS = 1;\n\nconst remainingMs = (deadline: number): number => Math.max(MINIMUM_TIMEOUT_MS, deadline - nowMs());\n\nexport const verdictsOf: {\n (request: DecisionRequest): (result: DecideResult) => VerdictResult;\n (result: DecideResult, request: DecisionRequest): VerdictResult;\n} = Fn.dual(DATA_FIRST_ARITY, (result: DecideResult, request: DecisionRequest): VerdictResult => {\n if (!result.ok) {\n return result;\n }\n return runOrElse(\n Effect.sync((): VerdictResult => ({\n ok: true,\n verdicts: parseVerdicts(result.response, request),\n cached: result.cached,\n })),\n (cause) => ({ ok: false, reason: messageOf(cause) }),\n );\n});\n\nexport const inputOf: {\n (request: DecisionRequest): (asking: Asking) => DecideInput;\n (asking: Asking, request: DecisionRequest): DecideInput;\n} = Fn.dual(DATA_FIRST_ARITY, (asking: Asking, request: DecisionRequest): DecideInput => ({\n request,\n timeoutMs: remainingMs(asking.deadline),\n env: asking.env,\n}));\n\nconst fetchVerdicts = (asking: Asking, request: DecisionRequest): VerdictResult =>\n verdictsOf(asking.model.provider.decide(inputOf(asking, request)), request);\n\nconst isRange = (location: Option.Option<LineRange>): location is Option.Some<LineRange> =>\n Option.exists(location, ({ start, end }) => start !== end);\n\nconst refineOnce = (\n { asking, match, ref, state }: Refinement,\n within: LineRange,\n): VerdictResult & { readonly next?: Option.Option<LineRange> } => {\n const questionId = locationRefOf(ref);\n const candidates = locationCandidates(match.snippet, within);\n const refined = fetchVerdicts(asking, {\n model: asking.model.model,\n state,\n questions: { [questionId]: locationQuestion(match, ref, candidates) },\n });\n if (!refined.ok) {\n return refined;\n }\n return {\n ...refined,\n next: selectedLocation(\n refined.verdicts.answers[questionId],\n candidates,\n match.rule.location.cutoff,\n ),\n };\n};\n\nconst refine = (refinement: Refinement, first: Option.Option<LineRange>): Located => {\n let location = first;\n while (isRange(location)) {\n const step = refineOnce(refinement, location.value);\n if (!step.ok) {\n return { loc: refinement.match.loc, failure: Option.some(step.reason) };\n }\n location = step.next ?? Option.none();\n }\n return {\n loc: Option.match(location, {\n onNone: () => refinement.match.loc,\n onSome: ({ start }) => locationOfLine(refinement.match.snippet, start),\n }),\n failure: Option.none(),\n };\n};\n\nexport interface LocateInput {\n readonly ref: string;\n readonly verdicts: Verdicts;\n readonly request: DecisionRequest;\n}\n\nexport const locateMatch: {\n (match: Match, input: LocateInput): (asking: Asking) => Located;\n (asking: Asking, match: Match, input: LocateInput): Located;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (asking: Asking, match: Match, { ref, verdicts, request }: LocateInput): Located => {\n if (!locates(match)) {\n return { loc: match.loc, failure: Option.none() };\n }\n const first = selectedLocation(\n verdicts.answers[locationRefOf(ref)],\n locationCandidates(match.snippet, EVERY_LINE),\n match.rule.location.cutoff,\n );\n return refine({ asking, match, ref, state: request.state }, first);\n },\n);\n","import type { Context, Location } from \"@oxlint/plugins\";\nimport { Array as Arr, Boolean as Bool, Option, Record as Rec, pipe } from \"effect\";\n\nimport {\n isReported,\n OUT_OF_BUDGET,\n optionsError,\n buildRequest,\n refAt,\n failsInCi,\n warnOnce,\n} from \"#/entities/decision/index.ts\";\nimport type {\n DecideResult,\n DecisionProvider,\n DecisionRequest,\n Match,\n ModelRef,\n ResolvedOptions,\n Verdicts,\n} from \"#/entities/decision/index.ts\";\n\nimport { explainerFor } from \"./explain.ts\";\nimport type { ExplainPass, Explainer, Outcome, Placed } from \"./explain.ts\";\nimport { inputOf, locateMatch, verdictsOf } from \"./locate.ts\";\nimport type { Asking, Located } from \"./locate.ts\";\n\nexport interface ModelPass {\n readonly contextOf: (match: Match) => Context;\n readonly filename: string;\n readonly options: ResolvedOptions;\n readonly model: ModelRef;\n readonly matches: readonly Match[];\n readonly deadline: number;\n}\n\ninterface Failure {\n readonly match: Match;\n readonly loc: Location;\n readonly reason: string;\n}\n\ninterface Answered {\n readonly asking: Asking;\n readonly verdicts: Verdicts;\n readonly request: DecisionRequest;\n readonly cached: boolean | undefined;\n readonly explainer: Explainer;\n}\n\nconst DECIMALS = 2;\n\nconst failsHere = (pass: ModelPass, reason: string): boolean =>\n failsInCi(pass.options) && !OUT_OF_BUDGET.test(reason);\n\nconst degrade = (pass: ModelPass, reason: string): void => {\n if (failsHere(pass, reason)) {\n throw optionsError(`${reason} (${pass.filename})`);\n }\n warnOnce(reason, `${reason} (${pass.filename})`);\n};\n\nconst reportFailure = (pass: ModelPass, failure: Failure): void => {\n if (failsHere(pass, failure.reason)) {\n pass.contextOf(failure.match).report({\n loc: failure.loc,\n messageId: \"unlocated\",\n data: { id: failure.match.rule.id, reason: failure.reason },\n });\n return;\n }\n warnOnce(failure.reason, `${failure.reason} (${pass.filename})`);\n};\n\nconst locate = (\n answered: Answered,\n match: Match,\n { ref, failed }: { readonly ref: string; readonly failed: boolean },\n): Located => {\n if (failed) {\n return { loc: match.loc, failure: Option.none() };\n }\n return locateMatch(answered.asking, match, { ...answered, ref });\n};\n\nconst outcomeOf = (answered: Answered, match: Match, ref: string): Outcome => {\n const verdict = Option.fromUndefinedOr(answered.verdicts.results[ref]);\n return {\n served: `${answered.asking.model.provider.name}/${answered.verdicts.model}`,\n cached: answered.cached,\n answers: answered.verdicts.answers,\n verdict,\n reported: Option.exists(verdict, (found) => isReported(match.rule, found)),\n };\n};\n\nconst reportMatch = (\n pass: ModelPass,\n answered: Answered,\n { match, ref, failed }: { readonly match: Match; readonly ref: string; readonly failed: boolean },\n): Option.Option<string> => {\n const outcome = outcomeOf(answered, match, ref);\n const { verdict } = outcome;\n if (!outcome.reported || Option.isNone(verdict)) {\n answered.explainer.outcome(match, { ref, loc: match.loc }, outcome);\n return Option.none();\n }\n const located = locate(answered, match, { ref, failed });\n const at: Placed = { ref, loc: located.loc };\n answered.explainer.outcome(match, at, outcome);\n pass.contextOf(match).report({\n loc: located.loc,\n messageId: \"yes\",\n data: {\n id: match.rule.id,\n model: `${pass.model.provider.name}/${answered.verdicts.model}`,\n answer: verdict.value.answer,\n score: verdict.value.probability.toFixed(DECIMALS),\n cutoff: match.rule.cutoff.toFixed(DECIMALS),\n question: match.rule.message ?? match.rule.question,\n },\n });\n return located.failure;\n};\n\nconst reportMatches = (pass: ModelPass, answered: Answered): Option.Option<Failure> => {\n let failure: Option.Option<Failure> = Option.none();\n for (const [index, match] of pass.matches.entries()) {\n const located = reportMatch(pass, answered, {\n match,\n ref: refAt(index),\n failed: Option.isSome(failure),\n });\n failure = Option.orElse(failure, () =>\n located.pipe(Option.map((reason) => ({ match, loc: match.loc, reason }))),\n );\n }\n return failure;\n};\n\nconst explainPassOf = (\n pass: ModelPass,\n { request, durationMs }: Pick<ExplainPass, \"request\" | \"durationMs\">,\n): ExplainPass => ({\n setting: pass.options.explain,\n cwd: Option.match(Arr.head(pass.matches), {\n onNone: () => \"\",\n onSome: (match) => pass.contextOf(match).cwd,\n }),\n filename: pass.filename,\n model: pass.model.id,\n yesNo: pass.model.provider.yesNo === true,\n request,\n durationMs,\n});\n\nconst explainerOf = (\n pass: ModelPass,\n timed: Pick<ExplainPass, \"request\" | \"durationMs\">,\n): Explainer => explainerFor(explainPassOf(pass, timed));\n\ninterface Prepared {\n readonly pass: ModelPass;\n readonly asking: Asking;\n readonly request: DecisionRequest;\n}\n\nconst prepare = (pass: ModelPass): Prepared => ({\n pass,\n asking: { model: pass.model, deadline: pass.deadline, env: pass.options.env },\n request: buildRequest(pass.model.model, pass.matches),\n});\n\nconst reportAnswer = (\n { pass, asking, request }: Prepared,\n { decided, durationMs }: { readonly decided: DecideResult; readonly durationMs: number },\n): void => {\n const explainer = explainerOf(pass, { request, durationMs });\n const result = verdictsOf(decided, request);\n if (!result.ok) {\n explainer.failure(pass.matches, result.reason);\n degrade(pass, result.reason);\n return;\n }\n Option.map(reportMatches(pass, { ...result, asking, request, explainer }), (failure) => {\n reportFailure(pass, failure);\n });\n};\n\nconst decideWith = (\n provider: DecisionProvider,\n prepared: readonly Prepared[],\n): readonly DecideResult[] => {\n const inputs = pipe(\n prepared,\n Arr.map(({ asking, request }) => inputOf(asking, request)),\n );\n return Option.match(Option.fromUndefinedOr(provider.decideAll), {\n onNone: () =>\n pipe(\n inputs,\n Arr.map((input) => provider.decide(input)),\n ),\n onSome: (decideAll) => decideAll(inputs),\n });\n};\n\nconst reportProvider = (prepared: Arr.NonEmptyReadonlyArray<Prepared>): void => {\n const { provider } = Arr.headNonEmpty(prepared).pass.model;\n const started = performance.now();\n const results = decideWith(provider, prepared);\n const durationMs = Math.round(performance.now() - started);\n const answers = Bool.match(results.length === prepared.length, {\n onTrue: () => results,\n onFalse: () =>\n pipe(\n prepared,\n Arr.map((): DecideResult => ({\n ok: false,\n reason: `provider ${provider.name} returned ${String(results.length)} results for ${String(prepared.length)} requests`,\n })),\n ),\n });\n for (const [one, decided] of Arr.zip(prepared, answers)) {\n reportAnswer(one, { decided, durationMs });\n }\n};\n\nexport const reportModels = (passes: readonly ModelPass[]): void => {\n const byProvider = Arr.groupBy(\n pipe(\n passes,\n Arr.map((pass) => prepare(pass)),\n ),\n ({ pass }) => pass.model.provider.name,\n );\n for (const prepared of Rec.values(byProvider)) {\n reportProvider(prepared);\n }\n};\n","import type { Context, VisitorWithHooks } from \"@oxlint/plugins\";\nimport { Array as Arr, Option, Predicate, Record as Rec, pipe, Function as Fn } from \"effect\";\n\nimport {\n commentedSnippetOf,\n contextOf,\n lacksComment,\n isSelected,\n REPORT_LOC,\n TARGET_NODE_TYPES,\n snippetNodeFor,\n optionsError,\n truncateSnippet,\n envNameOf,\n envOf,\n failsInCi,\n nowMs,\n warnOnce,\n} from \"#/entities/decision/index.ts\";\nimport type {\n AstNode,\n DecisionProvider,\n Match,\n ModelRef,\n ResolvedOptions,\n ResolvedRule,\n SelectedNode,\n Target,\n} from \"#/entities/decision/index.ts\";\n\nimport { reportModels } from \"./report.ts\";\nimport type { ModelPass } from \"./report.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport interface Collected {\n readonly options: ResolvedOptions;\n readonly contexts: Readonly<Record<string, Context>>;\n readonly rules: Readonly<Record<string, ResolvedRule>>;\n readonly matches: readonly Match[];\n}\n\nexport interface FileBatch extends Collected {\n readonly contexts: Record<string, Context>;\n readonly rules: Record<string, ResolvedRule>;\n readonly matches: Match[];\n exiting: boolean;\n exits: number;\n}\n\nexport interface RuleFile {\n readonly batch: FileBatch;\n readonly rule: ResolvedRule;\n}\n\nexport interface SharedFile {\n readonly join: (context: Context, id: string) => RuleFile;\n readonly leave: () => void;\n}\n\nexport type OptionsFor = (settings: Readonly<Record<string, unknown>>) => ResolvedOptions;\n\nexport type RuleFor = (rule: ResolvedRule, options: unknown) => ResolvedRule;\n\nconst raisedMissing = new Set<string>();\n\nconst missingEnvOf = (options: ResolvedOptions, provider: DecisionProvider): readonly string[] =>\n pipe(\n provider.requiredEnv,\n Arr.map((name) => envNameOf(options.env, name)),\n Arr.filter((name) => Option.isNone(envOf(name))),\n );\n\nconst isAvailable = (options: ResolvedOptions, { provider }: ModelRef): boolean => {\n const missingNames = missingEnvOf(options, provider);\n if (Arr.isReadonlyArrayEmpty(missingNames)) {\n return true;\n }\n const missing = pipe(missingNames, Arr.join(\", \"));\n if (!failsInCi(options)) {\n warnOnce(`missing:${provider.name}`, `${missing} is not set, skipping ${provider.name} models`);\n } else if (!raisedMissing.has(provider.name)) {\n raisedMissing.add(provider.name);\n throw optionsError(`${missing} is not set`);\n }\n return false;\n};\n\nconst availableModels = (batch: Collected): readonly ModelRef[] => {\n const models = pipe(\n Rec.values(batch.rules),\n Arr.flatMap((rule) => rule.models),\n Arr.map((model) => [model.id, model] as const),\n );\n return pipe(\n Arr.fromIterable(new Map(models).values()),\n Arr.filter((model) => isAvailable(batch.options, model)),\n );\n};\n\nconst snippetOf = (context: Context, node: AstNode): string => {\n if (node.type === \"Program\") {\n return context.sourceCode.text;\n }\n return context.sourceCode.getText(node);\n};\n\nconst namedSnippetOf = (context: Context, node: AstNode): string => {\n const named = snippetNodeFor(node);\n if (named === node) {\n return snippetOf(context, node);\n }\n return context.sourceCode.getText(named);\n};\n\nconst matchOf = (\n context: Context,\n node: AstNode,\n { rule, options }: { readonly rule: ResolvedRule; readonly options: ResolvedOptions },\n): Match => {\n const text = Option.getOrElse(commentedSnippetOf(context, node, rule), () =>\n namedSnippetOf(context, node),\n );\n const surrounding = contextOf(context, node, rule.context ?? { scope: \"node\" });\n return {\n ...Option.match(surrounding, { onNone: () => ({}), onSome: (value) => ({ context: value }) }),\n rule,\n loc: REPORT_LOC[rule.target](node, snippetOf(context, node)),\n snippet: truncateSnippet(text, options.maxSnippetChars),\n truncated: text.length > options.maxSnippetChars,\n };\n};\n\nconst contextOfRule = (batch: Collected, id: string): Context =>\n Option.getOrThrow(Option.fromUndefinedOr(batch.contexts[id]));\n\nconst finish = (batch: Collected): void => {\n const [first] = Rec.values(batch.contexts);\n if (Predicate.isUndefined(first)) {\n return;\n }\n const deadline = nowMs() + batch.options.timeoutMs;\n const passes = pipe(\n availableModels(batch),\n Arr.flatMap((model): readonly ModelPass[] => {\n const matches = pipe(\n batch.matches,\n Arr.filter(({ rule }) =>\n pipe(\n rule.models,\n Arr.some(({ id }) => id === model.id),\n ),\n ),\n );\n return Arr.match(matches, {\n onEmpty: () => [],\n onNonEmpty: (some) => [\n {\n contextOf: (match) => contextOfRule(batch, match.rule.id),\n filename: first.filename,\n options: batch.options,\n model,\n matches: some,\n deadline,\n },\n ],\n });\n }),\n );\n reportModels(passes);\n};\n\nconst ruleIn = (batch: Collected, id: string): ResolvedRule =>\n Option.getOrThrow(Arr.findFirst(batch.options.rules, (rule) => rule.id === id));\n\nexport const sharedFile: {\n (ruleFor: RuleFor): (optionsFor: OptionsFor) => SharedFile;\n (optionsFor: OptionsFor, ruleFor: RuleFor): SharedFile;\n} = Fn.dual(DATA_FIRST_ARITY, (optionsFor: OptionsFor, ruleFor: RuleFor): SharedFile => {\n let current: Option.Option<FileBatch> = Option.none();\n const start = (context: Context): FileBatch => {\n const batch: FileBatch = {\n options: optionsFor(context.settings),\n contexts: {},\n rules: {},\n matches: [],\n exiting: false,\n exits: 0,\n };\n current = Option.some(batch);\n return batch;\n };\n return {\n join: (context, id) => {\n const batch = Option.match(current, {\n onNone: () => start(context),\n onSome: (open) => {\n if (open.exiting) {\n return start(context);\n }\n return open;\n },\n });\n const [options] = context.options;\n const rule = ruleFor(ruleIn(batch, id), options);\n batch.contexts[id] = context;\n batch.rules[id] = rule;\n return { batch, rule };\n },\n leave: () => {\n if (Option.isNone(current)) {\n return;\n }\n const batch = current.value;\n batch.exits += 1;\n if (batch.exits >= Rec.keys(batch.contexts).length) {\n current = Option.none();\n }\n if (!batch.exiting) {\n batch.exiting = true;\n finish(batch);\n }\n },\n };\n});\n\ntype Visited = SelectedNode & AstNode;\n\nconst isSkipped = (context: Context, node: Visited, rule: ResolvedRule): boolean =>\n !isSelected(context, node, rule) || lacksComment(context, node, rule);\n\nexport interface RuleTarget {\n readonly id: string;\n readonly target: Target;\n}\n\nexport const visitorFor: {\n (rule: RuleTarget): (shared: SharedFile) => (context: Context) => VisitorWithHooks;\n (shared: SharedFile, rule: RuleTarget): (context: Context) => VisitorWithHooks;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (shared: SharedFile, { id, target }: RuleTarget) =>\n (context: Context): VisitorWithHooks => {\n let file: Option.Option<RuleFile> = Option.none();\n\n const collect = (node: Visited): void => {\n if (Option.isNone(file)) {\n return;\n }\n const { batch, rule } = file.value;\n if (isSkipped(context, node, rule)) {\n return;\n }\n batch.matches.push(matchOf(context, node, { rule, options: batch.options }));\n };\n\n const nodeTypes: readonly string[] = TARGET_NODE_TYPES[target];\n\n return {\n ...Rec.fromEntries(\n pipe(\n nodeTypes,\n Arr.map((type) => [type, collect]),\n ),\n ),\n Program: (node: Visited): void => {\n file = Option.some(shared.join(context, id));\n if (target === \"file\") {\n collect(node);\n }\n },\n \"Program:exit\": (): void => {\n file = Option.none();\n shared.leave();\n },\n };\n },\n);\n","import type { Plugin, RuleMeta } from \"@oxlint/plugins\";\nimport { Predicate, Array as Arr, Record as Rec, Struct, pipe } from \"effect\";\n\nimport { PREFIX, checkRules, resolveOptions, toJson } from \"#/entities/decision/index.ts\";\nimport type {\n DecisionOptions,\n DecisionPlugin,\n DecisionPluginSetup,\n DecisionProvider,\n DecisionRule,\n ResolvedOptions,\n ResolvedRule,\n} from \"#/entities/decision/index.ts\";\nimport {\n RULE_OPTIONS_SCHEMA,\n overrideRule,\n sharedFile,\n visitorFor,\n} from \"#/features/judge-code/index.ts\";\n\nimport { cloudflare } from \"./cloudflare.ts\";\nimport { openRouter } from \"./openrouter.ts\";\n\nconst DEFAULT_NAME = \"decision\";\n\nconst metaOf = (rule: DecisionRule): RuleMeta => ({\n type: \"problem\",\n docs: { description: rule.question },\n schema: RULE_OPTIONS_SCHEMA,\n messages: {\n yes: \"[{{id}}] {{model}} answered {{answer}} ({{score}} >= {{cutoff}}): {{question}}\",\n unlocated: `${PREFIX}: {{reason}} while refining the location of [{{id}}]; the finding is reported at the file level`,\n },\n});\n\nconst optionsOf = (setup: DecisionPluginSetup): DecisionOptions =>\n Struct.omit(setup, [\"name\", \"rules\", \"providers\"]);\n\ntype Resolve = (settings: unknown) => ResolvedOptions;\n\nconst memoized = (resolve: Resolve): Resolve => {\n const resolved = new Map<string, ResolvedOptions>();\n return (settings) => {\n const key = toJson([settings]);\n const cached = resolved.get(key);\n if (Predicate.isNotUndefined(cached)) {\n return cached;\n }\n const fresh = resolve(settings);\n resolved.set(key, fresh);\n return fresh;\n };\n};\n\nconst memoizedRules = (\n providers: Readonly<Record<string, DecisionProvider>>,\n): ((rule: ResolvedRule, options: unknown) => ResolvedRule) => {\n const resolved = new WeakMap<ResolvedRule, Map<string, ResolvedRule>>();\n return (rule, options) => {\n const known = resolved.get(rule) ?? new Map<string, ResolvedRule>();\n resolved.set(rule, known);\n const key = toJson([options]);\n const cached = known.get(key);\n if (Predicate.isNotUndefined(cached)) {\n return cached;\n }\n const fresh = overrideRule(rule, options, providers);\n known.set(key, fresh);\n return fresh;\n };\n};\n\nexport const createDecisionPlugin = (setup: DecisionPluginSetup): DecisionPlugin => {\n const name = setup.name ?? DEFAULT_NAME;\n const providers: Readonly<Record<string, DecisionProvider>> = Rec.fromEntries(\n pipe(\n [cloudflare, openRouter, ...(setup.providers ?? [])],\n Arr.map((provider) => [provider.name, provider]),\n ),\n );\n const rules = checkRules(setup.rules);\n const options = optionsOf(setup);\n const resolve = memoized((settings) => resolveOptions({ options, settings }, rules, providers));\n resolve({});\n const shared = sharedFile((settings) => resolve(settings[name]), memoizedRules(providers));\n\n return {\n meta: { name },\n rules: Rec.fromEntries(\n pipe(\n rules,\n Arr.map((rule) => [rule.id, { meta: metaOf(rule), createOnce: visitorFor(shared, rule) }]),\n ),\n ),\n } satisfies Plugin;\n};\n"],"mappings":";;;;AAAA,MAAa,gBAAgB;;ACE7B,MAAa,sBAAuD,SAAqB;AAEzF,MAAa,kBACX,aACa;;ACCf,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAgBzB,MAAM,0BAAU,IAAI,IAA6B;AAEjD,MAAM,aAAa,WAAwB;CACzC,MAAM,YAAY,KAChBA,SAAI,MAAM,gBAAgB,CAAC,CAAC,YAAY,GAAG,GAC3C,OAAO,QAAQC,MAAI,IAAI,GACvB,OAAO,gBAAgB,eAAe,CACxC;CACA,OAAO,IAAI,IAAI,GAAG,SAAS,aAAa,YAAY,GAAG;AACzD;AAEA,MAAM,cAAc,WAAoC;CACtD,MAAM,WAAW,QAAQ,IAAI,MAAM;CACnC,IAAI,UAAU,eAAe,QAAQ,GACnC,OAAO;CAET,MAAM,UAAU,aAAqB,UAAU,MAAM,GAAG,EAAE,SAAS,YAA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