@r_masseater/oxlint-plugin-decision 0.7.0 → 0.8.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.
- package/README.md +17 -3
- package/dist/{app-Bso1uwY5.mjs → app-D2bguKZ_.mjs} +182 -88
- package/dist/app-D2bguKZ_.mjs.map +1 -0
- package/dist/claim-rule-B0LCcxxc.mjs +36 -0
- package/dist/claim-rule-B0LCcxxc.mjs.map +1 -0
- package/dist/cloudflare-worker.mjs +111 -3
- package/dist/cloudflare-worker.mjs.map +1 -1
- package/dist/{index-BOrpK3Iv.d.mts → index-B4wX62VC.d.mts} +2 -2
- package/dist/{index-Cgg-w0hb.d.mts → index-CK88FBE5.d.mts} +691 -349
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +1 -1
- package/dist/{define-presets-clyqLZxo.mjs → preset-plugin-MKdvpXxa.mjs} +11 -214
- package/dist/preset-plugin-MKdvpXxa.mjs.map +1 -0
- package/dist/presets/ai-slop.d.mts +2 -3
- package/dist/presets/ai-slop.mjs +179 -2
- package/dist/presets/ai-slop.mjs.map +1 -1
- 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 +1 -2
- package/dist/presets/recommended.mjs.map +1 -1
- package/dist/presets/review-only.d.mts +1 -2
- package/dist/presets/review-only.mjs +1 -2
- package/dist/presets/review-only.mjs.map +1 -1
- package/dist/presets/strict.d.mts +1 -2
- package/dist/presets/strict.mjs +1 -2
- package/dist/presets/strict.mjs.map +1 -1
- package/dist/serve-decisions-D6M-l2uy.mjs +232 -0
- package/dist/serve-decisions-D6M-l2uy.mjs.map +1 -0
- package/dist/typesafe-worker.mjs +29 -0
- package/dist/typesafe-worker.mjs.map +1 -0
- package/dist/{decision-BtTZ52be.mjs → wire-CKpt_MBX.mjs} +56 -261
- package/dist/wire-CKpt_MBX.mjs.map +1 -0
- package/package.json +26 -29
- package/skills/write-decision-rules/SKILL.md +6 -7
- package/skills/write-decision-rules/references/tuning.md +3 -5
- package/dist/app-Bso1uwY5.mjs.map +0 -1
- package/dist/decision-BtTZ52be.mjs.map +0 -1
- package/dist/define-presets-clyqLZxo.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/preset-plugin-AAwedMeS.mjs +0 -10
- package/dist/preset-plugin-AAwedMeS.mjs.map +0 -1
- package/dist/serve-decisions-CjlhvYm7.mjs +0 -290
- 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,55 +0,0 @@
|
|
|
1
|
-
# Custom providers
|
|
2
|
-
|
|
3
|
-
Read this when rules must ask a service other than Cloudflare and OpenRouter. `cloudflare/<model>` and `openrouter/<model>` are built in and need no provider code.
|
|
4
|
-
|
|
5
|
-
## Define and register a provider
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
// decision-plugin.mjs
|
|
9
|
-
import {
|
|
10
|
-
createDecisionPlugin,
|
|
11
|
-
defineDecisionRule,
|
|
12
|
-
defineProvider,
|
|
13
|
-
} from "@r_masseater/oxlint-plugin-decision";
|
|
14
|
-
|
|
15
|
-
export default createDecisionPlugin({
|
|
16
|
-
name: "team",
|
|
17
|
-
model: "internal/v2",
|
|
18
|
-
rules: [
|
|
19
|
-
defineDecisionRule({
|
|
20
|
-
id: "no-swallowed-catch",
|
|
21
|
-
target: "function",
|
|
22
|
-
question: "Does this function catch an error and neither handle nor rethrow it?",
|
|
23
|
-
cutoff: 0.8,
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
providers: [
|
|
27
|
-
defineProvider({
|
|
28
|
-
name: "internal",
|
|
29
|
-
requiredEnv: ["INTERNAL_DECIDER_KEY"],
|
|
30
|
-
decide: ({ request, timeoutMs, env }) => {
|
|
31
|
-
const key = process.env[env.INTERNAL_DECIDER_KEY ?? "INTERNAL_DECIDER_KEY"];
|
|
32
|
-
return { ok: true, response: callYourDecider(request, key, timeoutMs) };
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
36
|
-
});
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
A model id `internal/v2` routes to the provider named `internal` and sends `model: "v2"` in the request. An id whose provider is not registered makes the plugin throw at load time.
|
|
40
|
-
|
|
41
|
-
`requiredEnv` lists the variables the provider needs. The plugin checks them before calling `decide`, after applying the `env` renames. When one is missing, it warns once and reports nothing for that model. In CI with `ci: "fail"`, it fails the run instead.
|
|
42
|
-
|
|
43
|
-
`env` in the `decide` input is the rename map from settings, not the values. Read `process.env[env[name] ?? name]` yourself.
|
|
44
|
-
|
|
45
|
-
## The `decide` contract
|
|
46
|
-
|
|
47
|
-
`decide` is synchronous because oxlint rules are. A provider that calls a network service must block on a worker thread. The built-in provider does that with [synckit](https://github.com/un-ts/synckit). Returning a Promise is not supported.
|
|
48
|
-
|
|
49
|
-
The input is `{ request, timeoutMs, env }`. `request` is an OpenRouter Decisions request with `model`, `state` and `questions`. `state` holds `snippets` keyed by match id and optional `contexts`. Each question is `{ type: "noul", instructions }` or `{ type: "choice", instructions, criteria }`.
|
|
50
|
-
|
|
51
|
-
The output is `{ ok: true, response }` with a Decisions response body, or `{ ok: false, reason }`. A failure is a warning (or a CI failure), never an exception. Do not throw from `decide`. Respect `timeoutMs`, which is the remaining per-file budget.
|
|
52
|
-
|
|
53
|
-
Optional `decideAll(inputs)` gets every model of one file for this provider at once. It returns one result per input, in the same order. Send them concurrently there. Without it, the plugin calls `decide` once per model, one after another. A result count that differs from the input count fails every input of that call.
|
|
54
|
-
|
|
55
|
-
To check the provider, run oxlint with `OXLINT_DECISION_EXPLAIN=1`. Each match should show your model id and a probability, not an `error` line.
|
|
File without changes
|