@r_masseater/oxlint-plugin-decision 0.8.3 → 0.9.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 +2 -0
- package/dist/{app-D2bguKZ_.mjs → app-BO1xNTFk.mjs} +80 -10
- package/dist/app-BO1xNTFk.mjs.map +1 -0
- package/dist/{claim-rule-B0LCcxxc.mjs → claim-rule-BtckE1OP.mjs} +2 -2
- package/dist/{claim-rule-B0LCcxxc.mjs.map → claim-rule-BtckE1OP.mjs.map} +1 -1
- package/dist/cloudflare-worker.mjs +2 -2
- package/dist/{index-CK88FBE5.d.mts → index-B2bdY9ax.d.mts} +28 -2
- package/dist/{index-B4wX62VC.d.mts → index-YYrIqZKY.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{preset-plugin-MKdvpXxa.mjs → preset-plugin-DlO5OR3z.mjs} +3 -3
- package/dist/{preset-plugin-MKdvpXxa.mjs.map → preset-plugin-DlO5OR3z.mjs.map} +1 -1
- package/dist/presets/ai-slop.d.mts +2 -2
- 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 -1
- package/dist/presets/recommended.mjs +1 -1
- package/dist/presets/review-only.d.mts +1 -1
- package/dist/presets/review-only.mjs +1 -1
- package/dist/presets/strict.d.mts +1 -1
- package/dist/presets/strict.mjs +1 -1
- package/dist/{serve-decisions-D6M-l2uy.mjs → serve-decisions-vZr4L2TM.mjs} +2 -2
- package/dist/{serve-decisions-D6M-l2uy.mjs.map → serve-decisions-vZr4L2TM.mjs.map} +1 -1
- package/dist/typesafe-worker.mjs +2 -2
- package/dist/{wire-CKpt_MBX.mjs → wire-D0YSbfBG.mjs} +3 -2
- package/dist/wire-D0YSbfBG.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/app-D2bguKZ_.mjs.map +0 -1
- package/dist/wire-CKpt_MBX.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app-D2bguKZ_.mjs","names":["Str","Arr","FIRST_LINE","Rec","Str","DATA_FIRST_ARITY_3","Arr","Str","Fn","DATA_FIRST_ARITY_3","Str","Fn","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","Str","Arr","Rec","Arr"],"sources":["../src/entities/decision/model/budget.ts","../../lint-host/src/shared/lib/collections.ts","../src/entities/decision/model/nodes.ts","../src/entities/decision/model/context.ts","../src/entities/decision/model/define.ts","../src/entities/decision/model/name.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/sync-provider.ts","../src/app/cloudflare.ts","../src/app/typesafe.ts","../src/app/plugin.ts"],"sourcesContent":["export const OUT_OF_BUDGET = /^http (?:402|403): .*(?:credit|budget)/iu;\n","import { Array as Arr, Option, Order, Record as Rec, String as Str, pipe } from \"effect\";\n\nconst byKey = Order.mapInput(Str.Order, ([key]: readonly [string, unknown]) => key);\n\nexport const sortedRecord = <Value>(\n entries: readonly (readonly [string, Value])[],\n): Readonly<Record<string, Value>> => Rec.fromEntries(Arr.sort(entries, byKey));\n\nconst NEXT = 1;\n\nexport interface Grouped<Head, Item> {\n readonly head: Head;\n readonly items: readonly Item[];\n}\n\nexport const groupedUnder =\n <Item, Head>(asHead: (item: Item) => Option.Option<Head>) =>\n (closes: (head: Head, item: Item) => boolean) =>\n (items: readonly Item[]): readonly Grouped<Head, Item>[] =>\n pipe(\n items,\n Arr.flatMap((item, index) =>\n pipe(\n asHead(item),\n Option.map((head): Grouped<Head, Item> => ({\n head,\n items: pipe(\n items,\n Arr.drop(index + NEXT),\n Arr.takeWhile((next) => !closes(head, next)),\n ),\n })),\n Option.toArray,\n ),\n ),\n );\n\nexport const ancestorsBy =\n <Node>(parentOf: (node: Node) => Option.Option<Node>) =>\n (node: Node): readonly Node[] =>\n Arr.unfold(parentOf(node), (current) =>\n pipe(\n current,\n Option.map((found) => [found, parentOf(found)] as const),\n ),\n );\n\nexport const groupOf =\n (name: string) =>\n (found: RegExpMatchArray | null): Option.Option<string> =>\n pipe(\n Option.fromNullishOr(found),\n Option.flatMap((match) => Option.fromNullishOr(match.groups)),\n Option.flatMap((groups) => Option.fromNullishOr(groups[name])),\n );\n","import type { Location } from \"@oxlint/plugins\";\nimport { Option, String as Str, Record as Rec } from \"effect\";\n\nimport type { AstNode, Target } from \"./types.ts\";\n\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 0;\nexport const TARGET_NODE_TYPES = {\n function: [\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"],\n call: [\"CallExpression\"],\n jsx: [\"JSXElement\"],\n file: [\"Program\"],\n} as const satisfies Readonly<Record<Target, readonly string[]>>;\n\nconst NAMED_PARENTS = {\n VariableDeclarator: \"init\",\n Property: \"value\",\n MethodDefinition: \"value\",\n PropertyDefinition: \"value\",\n} as const;\n\ntype NamedField = (typeof NAMED_PARENTS)[keyof typeof NAMED_PARENTS];\n\nconst NAMED_PARENT_TYPES: ReadonlySet<string> = new Set(Rec.keys(NAMED_PARENTS));\n\nconst isNamedParentType = (type: string): type is keyof typeof NAMED_PARENTS =>\n NAMED_PARENT_TYPES.has(type);\n\nconst ANONYMOUS_FUNCTIONS: ReadonlySet<string> = new Set([\n \"FunctionExpression\",\n \"ArrowFunctionExpression\",\n]);\n\nconst holdsAsName = (parent: AstNode, node: AstNode): boolean => {\n if (!isNamedParentType(parent.type)) {\n return false;\n }\n const field: NamedField = NAMED_PARENTS[parent.type];\n return ANONYMOUS_FUNCTIONS.has(node.type) && parent[field] === node;\n};\n\nexport const snippetNodeFor = (node: AstNode): AstNode =>\n Option.fromNullishOr(node.parent).pipe(\n Option.filter((parent) => holdsAsName(parent, node)),\n Option.getOrElse((): AstNode => node),\n );\nconst headOf = (text: string, line: number, column: number): Location => {\n const [first] = Str.split(text, \"\\n\");\n return { start: { line, column }, end: { line, column: column + first.length } };\n};\n\nexport const REPORT_LOC = {\n function: (node: AstNode, text: string): Location =>\n headOf(text, node.loc.start.line, node.loc.start.column),\n call: (node: AstNode): Location => node.loc,\n jsx: (node: AstNode): Location =>\n Option.getOrElse(Option.fromNullishOr(node.openingElement), () => node).loc,\n file: (_node: AstNode, text: string): Location => headOf(text, FIRST_LINE, FIRST_COLUMN),\n} as const satisfies Readonly<Record<Target, (node: AstNode, text: string) => Location>>;\n","import { ancestorsBy } from \"@masseater.dev/lint-host/collections\";\nimport type { Context } from \"@oxlint/plugins\";\nimport { Array as Arr, Option, Predicate, String as Str, pipe, Function as Fn } from \"effect\";\n\nimport { sourceLines } from \"./location.ts\";\nimport { snippetNodeFor } from \"./nodes.ts\";\nimport type { AstNode, EnclosingKind, ResolvedRule, RuleContext } from \"./types.ts\";\n\nconst DATA_FIRST_ARITY_3 = 3;\n\nconst DEFAULT_LINES = 5;\nconst FIRST_LINE = 1;\nconst LAST = 1;\nconst END = 1;\n\nconst ENCLOSING_TYPES: Readonly<Record<EnclosingKind, readonly string[]>> = {\n function: [\"FunctionDeclaration\", \"FunctionExpression\", \"ArrowFunctionExpression\"],\n class: [\"ClassDeclaration\", \"ClassExpression\"],\n block: [\"BlockStatement\", \"StaticBlock\", \"Program\"],\n};\n\nconst ancestorsOf = ancestorsBy((node: AstNode) => Option.fromNullishOr(node.parent));\n\nconst enclosingText = (context: Context, node: AstNode, kind: EnclosingKind): string =>\n Arr.findFirst(ancestorsOf(node), (ancestor) =>\n ENCLOSING_TYPES[kind].includes(ancestor.type),\n ).pipe(\n Option.match({\n onNone: () => context.sourceCode.text,\n onSome: (ancestor) => context.sourceCode.getText(ancestor),\n }),\n );\n\nconst linesAround = (\n context: Context,\n node: AstNode,\n {\n before = DEFAULT_LINES,\n after = DEFAULT_LINES,\n }: { readonly before?: number; readonly after?: number },\n): string => {\n const lines = sourceLines(context.sourceCode.text);\n const first = Math.max(FIRST_LINE, node.loc.start.line - before);\n const last = Math.min(lines.length, node.loc.end.line + after);\n return pipe(\n lines,\n Arr.drop(first - FIRST_LINE),\n Arr.take(last - first + FIRST_LINE),\n Arr.map((text, index) => `L${String(first + index)}| ${text}`),\n Arr.join(\"\\n\"),\n );\n};\n\nconst DECLARING_PARENTS: ReadonlySet<string> = new Set([\n \"VariableDeclaration\",\n \"ExportNamedDeclaration\",\n \"ExportDefaultDeclaration\",\n]);\n\nconst declarationOf = (node: AstNode): AstNode =>\n Option.fromNullishOr(node.parent).pipe(\n Option.filter((parent) => DECLARING_PARENTS.has(parent.type)),\n Option.match({ onNone: () => node, onSome: declarationOf }),\n );\n\ninterface Span {\n readonly start: number;\n readonly end: number;\n}\n\nconst leadingOf = (text: string, comments: readonly Span[], until: number): readonly Span[] =>\n Option.match(Arr.last(comments), {\n onNone: () => [],\n onSome: (last) => {\n if (Str.isNonEmpty(Str.trim(Str.slice(last.end, until)(text)))) {\n return [];\n }\n return [...leadingOf(text, Arr.dropRight(comments, LAST), last.start), last];\n },\n });\n\nconst commentedTextOf = (context: Context, node: AstNode): Option.Option<string> => {\n const { text } = context.sourceCode;\n const named = snippetNodeFor(node);\n const [start] = declarationOf(named).range;\n const before = pipe(\n context.sourceCode.getAllComments(),\n Arr.filter((comment) => comment.type !== \"Shebang\" && comment.end <= start),\n );\n return Arr.match(leadingOf(text, before, start), {\n onEmpty: () => Option.none(),\n onNonEmpty: ([first]) => Option.some(Str.slice(first.start, named.range[END])(text)),\n });\n};\n\nconst isCommented = ({ context: wanted }: ResolvedRule): boolean =>\n Predicate.isNotUndefined(wanted) && wanted.scope === \"comment\";\n\nexport const commentedSnippetOf: {\n (node: AstNode, rule: ResolvedRule): (context: Context) => Option.Option<string>;\n (context: Context, node: AstNode, rule: ResolvedRule): Option.Option<string>;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (context: Context, node: AstNode, rule: ResolvedRule): Option.Option<string> =>\n Option.flatMap(Option.liftPredicate(rule, isCommented), () => commentedTextOf(context, node)),\n);\n\nexport const lacksComment: {\n (node: AstNode, rule: ResolvedRule): (context: Context) => boolean;\n (context: Context, node: AstNode, rule: ResolvedRule): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (context: Context, node: AstNode, rule: ResolvedRule): boolean =>\n isCommented(rule) && Option.isNone(commentedTextOf(context, node)),\n);\n\nexport const contextOf: {\n (node: AstNode, rule: RuleContext): (context: Context) => Option.Option<string>;\n (context: Context, node: AstNode, rule: RuleContext): Option.Option<string>;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (context: Context, node: AstNode, rule: RuleContext): Option.Option<string> => {\n if (rule.scope === \"lines\") {\n return Option.some(linesAround(context, node, rule));\n }\n if (rule.scope === \"enclosing\") {\n return Option.some(enclosingText(context, node, rule.kind));\n }\n return Option.liftPredicate(context.sourceCode.text, () => rule.scope === \"file\");\n },\n);\n","import type { DecisionRule } from \"./types.ts\";\n\nexport const defineDecisionRule = <const Rule extends DecisionRule>(rule: Rule): Rule => rule;\n","import type { Context } from \"@oxlint/plugins\";\nimport { Match, Option, String as Str, Function as Fn } from \"effect\";\n\nimport type { DecisionRule, SelectedNode } from \"./types.ts\";\n\nconst DATA_FIRST_ARITY_3 = 3;\n\nconst heldName = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.flatMap(Option.fromNullishOr(node.parent), (parent) =>\n Match.value(parent).pipe(\n Match.when({ type: \"VariableDeclarator\" }, (holder) =>\n Option.liftPredicate(holder.id, () => holder.init === node),\n ),\n Match.when(\n { type: Match.is(\"Property\", \"MethodDefinition\", \"PropertyDefinition\") },\n (holder) => Option.liftPredicate(holder.key, () => holder.value === node),\n ),\n Match.orElse(() => Option.none<SelectedNode>()),\n ),\n );\n\nconst nameNodeOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(node).pipe(\n Match.when({ type: Match.is(\"FunctionDeclaration\", \"FunctionExpression\") }, (fn) =>\n Option.orElse(Option.fromNullishOr(fn.id), () => heldName(fn)),\n ),\n Match.when({ type: \"ArrowFunctionExpression\" }, heldName),\n Match.when({ type: Match.is(\"CallExpression\", \"NewExpression\") }, (call) =>\n Option.some(call.callee),\n ),\n Match.when({ type: \"JSXElement\" }, (element) => Option.some(element.openingElement.name)),\n Match.orElse(() => Option.none<SelectedNode>()),\n );\n\nconst nameOf = (node: SelectedNode, context: Context): string | undefined =>\n Option.getOrUndefined(\n Option.map(nameNodeOf(node), (name) =>\n Str.slice(name.start, name.end)(context.sourceCode.text),\n ),\n );\n\nexport const isSelected: {\n (node: SelectedNode, rule: DecisionRule): (context: Context) => boolean;\n (context: Context, node: SelectedNode, rule: DecisionRule): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (context: Context, node: SelectedNode, { select }: DecisionRule): boolean =>\n Option.match(Option.fromUndefinedOr(select), {\n onNone: () => true,\n onSome: (selects) => selects(node, { name: nameOf(node, context), context }),\n }),\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 { refAt, envOf, toJson, snippetRequestsFor } 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 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 return Option.fromUndefinedOr(answer.probabilities);\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 askedAbout =\n (ref: string) =>\n (wire: WireRequest): readonly (readonly [string, Question])[] =>\n pipe(\n Rec.toEntries(wire.questions),\n Arr.filter(([id]) => asksAbout(ref, id)),\n );\n\nconst sentFor = (\n sent: readonly WireRequest[],\n ref: string,\n): readonly (readonly [string, Question])[] => pipe(sent, Arr.flatMap(askedAbout(ref)));\n\nconst stateTextOf = (sent: readonly WireRequest[], ref: string, snippet: string): string =>\n Arr.findFirst(sent, (wire) => Arr.isReadonlyArrayNonEmpty(askedAbout(ref)(wire))).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 = snippetRequestsFor(pass.request);\n const print = printerFor(mode);\n return {\n outcome: (match, at, { served, answers, cached, verdict, reported }): void => {\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): void => {\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 request,\n durationMs,\n});\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 = explainerFor(explainPassOf(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 provider.decideAll(inputs);\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): RuleFile => {\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: (): void => {\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 { Array as Arr, Effect, Option, 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\"\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 workers.getOrInsertComputed(worker, () =>\n createSyncFn<Worker>(workerUrl(worker), { timeout: BACKSTOP_MS }),\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 { CLEF_MODEL } from \"#/entities/decision/index.ts\";\n\nimport { 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: CLEF_MODEL,\n});\n","import { JEV_MODEL } from \"#/entities/decision/index.ts\";\n\nimport { syncProvider } from \"./sync-provider.ts\";\n\nexport const typesafe = syncProvider({\n name: \"typesafe\",\n worker: \"typesafe-worker\",\n requiredEnv: [\"TYPESAFE_API_KEY\"],\n models: JEV_MODEL,\n});\n","import type { Plugin, RuleMeta } from \"@oxlint/plugins\";\nimport { 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 { typesafe } from \"./typesafe.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\"]);\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 return resolved.getOrInsertComputed(key, () => resolve(settings));\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.getOrInsertComputed(rule, () => new Map<string, ResolvedRule>());\n const key = toJson([options]);\n return known.getOrInsertComputed(key, () => overrideRule(rule, options, providers));\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, typesafe],\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;ACEf,MAAM,SAASA,SAAI,QAAQ,CAAC,SAAqC,GAAG;AAmClF,MAAa,eACJ,cACN,SACCC,MAAI,OAAO,SAAS,IAAI,IAAI,YAC1B,KACE,SACA,OAAO,KAAK,UAAU,CAAC,OAAO,SAAS,KAAK,CAAC,CAAU,CACzD,CACF;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AO,SAAS,CAAC;CAC9F,QAAQ,CAAC,CAAC;CACV,MAAM,SAAS,YAAY,aAAa,QAAQ,SAAS,KAAK,GAAG,cAAc,SAAS,CAAC;CAEzF,OAAO;EACL,MAAM,EAAE,KAAK;EACb,OAAOD,OAAI,YACT,KACE,OACAC,MAAI,KAAK,SAAS,CAAC,KAAK,IAAI;GAAE,MAAM,OAAO,IAAI;GAAG,YAAY,WAAW,QAAQ,IAAI;EAAE,CAAC,CAAC,CAC3F,CACF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wire-CKpt_MBX.mjs","names":["Arr","Rec","DATA_FIRST_ARITY","Rec","Fn","DATA_FIRST_ARITY","DATA_FIRST_ARITY_3","FIRST_LINE","Str","Num","Bool","Arr","Fn","Rec","DATA_FIRST_ARITY","Arr","Str","Fn","Rec","DATA_FIRST_ARITY","Bool","Str","Num","Fn","Arr","Rec","Fn","Str","Arr","Rec"],"sources":["../src/entities/decision/model/schema.ts","../src/entities/decision/model/answer.ts","../src/entities/decision/model/location.ts","../src/entities/decision/model/models.ts","../src/entities/decision/model/options.ts","../src/entities/decision/model/request.ts","../src/entities/decision/model/runtime.ts","../src/entities/decision/model/wire.ts"],"sourcesContent":["import { Schema, Array as Arr, Record as Rec, pipe } from \"effect\";\n\nconst NONE = 0;\nconst MINIMUM_LABELS = 2;\n\nconst NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(NONE));\n\nexport const Probability = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 1 }));\n\nexport const CONFIDENT = 0.8;\n\nexport const Cutoff = Schema.Finite.check(\n Schema.isBetween(\n { minimum: CONFIDENT, maximum: 1 },\n { message: `cutoff must be between ${CONFIDENT} and 1` },\n ),\n);\n\nexport const TargetSchema = Schema.Literals([\"function\", \"call\", \"jsx\", \"file\"]);\n\nexport const CiBehaviorSchema = Schema.Literals([\"skip\", \"fail\"]);\n\nexport const ExplainSettingSchema = Schema.Union([\n Schema.Boolean,\n Schema.Literals([\"text\", \"json\"]),\n]);\n\nexport const EnclosingKindSchema = Schema.Literals([\"function\", \"class\", \"block\"]);\n\nexport const RuleContextSchema = Schema.Union([\n Schema.Struct({ scope: Schema.Literals([\"node\", \"file\", \"comment\"]) }),\n Schema.Struct({\n scope: Schema.Literal(\"lines\"),\n before: Schema.optionalKey(NonNegativeInt),\n after: Schema.optionalKey(NonNegativeInt),\n }),\n Schema.Struct({ scope: Schema.Literal(\"enclosing\"), kind: EnclosingKindSchema }),\n]);\n\nexport const SeveritySchema = Schema.Literals([\"info\", \"warn\", \"error\"]);\n\nconst Label = Schema.NonEmptyString;\n\nconst BooleanAnswer = Schema.Struct({ kind: Schema.Literal(\"boolean\") });\n\nconst ClassifyAnswer = Schema.Struct({\n kind: Schema.Literal(\"classify\"),\n labels: Schema.Record(Label, Schema.String).check(Schema.isMinProperties(MINIMUM_LABELS)),\n report: Schema.NonEmptyArray(Label),\n}).check(\n Schema.makeFilter(\n ({ labels, report }) =>\n pipe(\n report,\n Arr.every((label) => Rec.has(labels, label)),\n ),\n {\n message: \"every label in report must be one of labels\",\n },\n ),\n);\n\nconst SeverityAnswer = Schema.Struct({\n kind: Schema.Literal(\"severity\"),\n minimum: Schema.optionalKey(SeveritySchema),\n});\n\nexport const RuleAnswerSchema = Schema.Union([BooleanAnswer, ClassifyAnswer, SeverityAnswer]);\n","import { Option, Result, Schema, Record as Rec, Function as Fn } from \"effect\";\n\nimport { Probability, RuleAnswerSchema } from \"./schema.ts\";\nimport type {\n Answer,\n ChoiceAnswer,\n NoulAnswer,\n Question,\n RuleAnswer,\n Severity,\n Verdict,\n} from \"./types.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nconst YES = \"yes\";\nconst DEFAULT_MINIMUM: Severity = \"warn\";\n\nconst SEVERITY_CRITERIA = {\n none: \"No problem\",\n info: \"Worth noting, but not a problem\",\n warn: \"Likely a problem\",\n error: \"Clearly a problem\",\n} as const;\n\nexport const SEVERITY_ORDER: readonly string[] = Rec.keys(SEVERITY_CRITERIA);\n\nexport const BOOLEAN_ANSWER: RuleAnswer = { kind: \"boolean\" };\n\nconst decodeAnswer = Schema.decodeUnknownResult(RuleAnswerSchema);\n\nexport const decodeRuleAnswer = (answer: unknown): Result.Result<RuleAnswer, string> => {\n const decoded = decodeAnswer(answer);\n if (Result.isSuccess(decoded)) {\n return Result.succeed(decoded.success);\n }\n return Result.fail(decoded.failure.message);\n};\n\nconst NoulAnswerSchema = Schema.Struct({ type: Schema.Literal(\"noul\"), noul: Probability });\n\nconst ChoiceAnswerSchema = Schema.Struct({\n type: Schema.Literal(\"choice\"),\n choice: Schema.String,\n probabilities: Schema.optional(Schema.Record(Schema.String, Probability)),\n} satisfies Partial<Record<keyof ChoiceAnswer, Schema.Top>>);\n\nexport const AnswerSchema = Schema.Union([NoulAnswerSchema, ChoiceAnswerSchema]);\n\nconst decodeNoul = Schema.decodeOption(NoulAnswerSchema);\n\nconst decodeChoice = Schema.decodeOption(ChoiceAnswerSchema);\n\nconst isNoul = (answer: Answer): answer is NoulAnswer => answer.type === \"noul\";\n\nconst isChoice = (answer: Answer): answer is ChoiceAnswer => answer.type === \"choice\";\n\nexport const noulOf = (answer: Answer | undefined): Option.Option<NoulAnswer> =>\n Option.fromUndefinedOr(answer).pipe(Option.filter(isNoul), Option.flatMap(decodeNoul));\n\nexport const choiceOf = (answer: Answer | undefined): Option.Option<ChoiceAnswer> =>\n Option.fromUndefinedOr(answer).pipe(Option.filter(isChoice), Option.flatMap(decodeChoice));\n\nexport const probabilityOfChoice = ({\n choice,\n probabilities,\n}: ChoiceAnswer): Option.Option<number> =>\n Option.fromUndefinedOr(probabilities).pipe(\n Option.flatMap((byLabel) => Option.fromUndefinedOr(byLabel[choice])),\n );\n\nexport const questionFor: {\n (instructions: string): (answer: RuleAnswer) => Question;\n (answer: RuleAnswer, instructions: string): Question;\n} = Fn.dual(DATA_FIRST_ARITY, (answer: RuleAnswer, instructions: string): Question => {\n switch (answer.kind) {\n case \"classify\": {\n return {\n type: \"choice\",\n instructions: `${instructions} Select the label that fits best.`,\n criteria: answer.labels,\n };\n }\n case \"severity\": {\n return {\n type: \"choice\",\n instructions: `${instructions} Rate how serious the problem is, and select none if there is no problem.`,\n criteria: SEVERITY_CRITERIA,\n };\n }\n case \"boolean\": {\n return { type: \"noul\", instructions };\n }\n default: {\n return { type: \"noul\", instructions };\n }\n }\n});\n\nconst choiceVerdictOf = (\n criteria: Readonly<Record<string, unknown>>,\n answer: Answer | undefined,\n): Option.Option<Verdict> =>\n choiceOf(answer).pipe(\n Option.filter(({ choice }) => Rec.has(criteria, choice)),\n Option.flatMap((chosen) =>\n Option.map(probabilityOfChoice(chosen), (probability) => ({\n answer: chosen.choice,\n probability,\n })),\n ),\n );\n\nexport const verdictOf: {\n (answer: Answer | undefined): (question: Question) => Option.Option<Verdict>;\n (question: Question, answer: Answer | undefined): Option.Option<Verdict>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (question: Question, answer: Answer | undefined): Option.Option<Verdict> => {\n if (question.type === \"choice\") {\n return choiceVerdictOf(question.criteria, answer);\n }\n return noulOf(answer).pipe(Option.map(({ noul }) => ({ answer: YES, probability: noul })));\n },\n);\n\nconst severityMatches = (\n { minimum = DEFAULT_MINIMUM }: { readonly minimum?: Severity },\n label: string,\n): boolean => SEVERITY_ORDER.indexOf(label) >= SEVERITY_ORDER.indexOf(minimum);\n\nconst answerMatches = (answer: RuleAnswer, label: string): boolean => {\n switch (answer.kind) {\n case \"classify\": {\n return answer.report.includes(label);\n }\n case \"severity\": {\n return severityMatches(answer, label);\n }\n case \"boolean\": {\n return label === YES;\n }\n default: {\n return false;\n }\n }\n};\n\nexport const isReported: {\n (verdict: Verdict): (rule: { readonly answer: RuleAnswer; readonly cutoff: number }) => boolean;\n (rule: { readonly answer: RuleAnswer; readonly cutoff: number }, verdict: Verdict): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (rule: { readonly answer: RuleAnswer; readonly cutoff: number }, verdict: Verdict): boolean =>\n verdict.probability >= rule.cutoff && answerMatches(rule.answer, verdict.answer),\n);\n","import type { Location } from \"@oxlint/plugins\";\nimport {\n Array as Arr,\n Boolean as Bool,\n Number as Num,\n Option,\n Predicate,\n String as Str,\n Record as Rec,\n pipe,\n Function as Fn,\n} from \"effect\";\n\nimport { choiceOf, probabilityOfChoice } from \"./answer.ts\";\nimport type { Answer, ChoiceQuestion, LineRange, RequestMatch, RuleLocation } from \"./types.ts\";\n\nconst DATA_FIRST_ARITY = 2;\nconst DATA_FIRST_ARITY_3 = 3;\nconst CHOICE_OPTION_LIMIT = 254;\nconst FIRST_LINE = 1;\nconst MINIMUM_WIDTH = 1;\nconst UNKNOWN_CHOICE = \"unknown\";\n\nexport const sourceLines = (text: string): readonly string[] =>\n Str.split(text, /\\r\\n|[\\n\\r\\u2028\\u2029]/u);\n\nexport type LocatedMatch = RequestMatch & {\n readonly rule: { readonly question: string; readonly location: RuleLocation };\n};\n\nexport const locates = (match: RequestMatch): match is LocatedMatch =>\n Predicate.isNotUndefined(match.rule.location) && !match.truncated;\n\nexport interface NumberedLine {\n readonly text: string;\n readonly line: number;\n}\n\nexport const EVERY_LINE: LineRange = { start: FIRST_LINE, end: Number.POSITIVE_INFINITY };\n\nconst isWithin = (line: number, within: LineRange): boolean =>\n Num.between(line, { minimum: within.start, maximum: within.end });\n\nconst rangeKey = ({ start, end }: LineRange): string =>\n Bool.match(start === end, {\n onTrue: () => `L${String(start)}`,\n onFalse: () => `L${String(start)}-L${String(end)}`,\n });\n\nconst rangeLabel = ({ start, end }: LineRange): string =>\n Bool.match(start === end, {\n onTrue: () => `Line ${String(start)}`,\n onFalse: () => `Lines ${String(start)} to ${String(end)}`,\n });\n\nconst rangeOf = (group: Arr.NonEmptyReadonlyArray<NumberedLine>): LineRange => ({\n start: Arr.headNonEmpty(group).line,\n end: Arr.lastNonEmpty(group).line,\n});\n\nexport const numberedLines = (snippet: string): readonly NumberedLine[] =>\n pipe(\n sourceLines(snippet),\n Arr.map((text, index) => ({ text, line: Num.sum(index, FIRST_LINE) })),\n );\n\nexport const locationCandidates: {\n (within: LineRange): (snippet: string) => Readonly<Record<string, LineRange>>;\n (snippet: string, within: LineRange): Readonly<Record<string, LineRange>>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (snippet: string, within: LineRange): Readonly<Record<string, LineRange>> => {\n const lines = pipe(\n numberedLines(snippet),\n Arr.filter(({ text, line }) => Str.trim(text).length >= FIRST_LINE && isWithin(line, within)),\n );\n const width = Math.max(MINIMUM_WIDTH, Math.ceil(lines.length / CHOICE_OPTION_LIMIT));\n return Rec.fromEntries(\n pipe(\n Arr.chunksOf(lines, width),\n Arr.map((group) => {\n const range = rangeOf(group);\n return [rangeKey(range), range];\n }),\n ),\n );\n },\n);\n\nexport const locationQuestion: {\n (\n ref: string,\n candidates: Readonly<Record<string, LineRange>>,\n ): (match: LocatedMatch) => ChoiceQuestion;\n (\n match: LocatedMatch,\n ref: string,\n candidates: Readonly<Record<string, LineRange>>,\n ): ChoiceQuestion;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (\n match: LocatedMatch,\n ref: string,\n candidates: Readonly<Record<string, LineRange>>,\n ): ChoiceQuestion => ({\n type: \"choice\",\n instructions: `Consider only the numbered source in state.snippets.${ref}. If it violates this rule, select the line (or range containing that line) to annotate. Rule: ${match.rule.question} Location: ${match.rule.location.question} If multiple violations exist, select the earliest one. Select ${UNKNOWN_CHOICE} if no violation exists or its location is unclear.`,\n criteria: {\n ...Rec.fromEntries(\n pipe(\n Rec.toEntries(candidates),\n Arr.map(([key, range]) => [key, rangeLabel(range)]),\n ),\n ),\n [UNKNOWN_CHOICE]: \"No clear source location for this violation\",\n },\n }),\n);\n\nexport type ChoiceCriteria = ChoiceQuestion[\"criteria\"];\n\nexport const validChoice: {\n (criteria: ChoiceCriteria): (answer: Answer | undefined) => boolean;\n (answer: Answer | undefined, criteria: ChoiceCriteria): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (answer: Answer | undefined, criteria: ChoiceCriteria): boolean =>\n Option.exists(\n choiceOf(answer),\n (chosen) => Rec.has(criteria, chosen.choice) && Option.isSome(probabilityOfChoice(chosen)),\n ),\n);\n\nexport const selectedLocation: {\n (\n candidates: Readonly<Record<string, LineRange>>,\n cutoff: number,\n ): (answer: Answer | undefined) => Option.Option<LineRange>;\n (\n answer: Answer | undefined,\n candidates: Readonly<Record<string, LineRange>>,\n cutoff: number,\n ): Option.Option<LineRange>;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (\n answer: Answer | undefined,\n candidates: Readonly<Record<string, LineRange>>,\n cutoff: number,\n ): Option.Option<LineRange> =>\n choiceOf(answer).pipe(\n Option.filter((chosen) =>\n Option.exists(probabilityOfChoice(chosen), (probability) =>\n Num.isGreaterThanOrEqualTo(probability, cutoff),\n ),\n ),\n Option.flatMap(({ choice }) => Option.fromUndefinedOr(candidates[choice])),\n ),\n);\n\nexport const locationOfLine: {\n (line: number): (snippet: string) => Location;\n (snippet: string, line: number): Location;\n} = Fn.dual(DATA_FIRST_ARITY, (snippet: string, line: number): Location => {\n const text = Option.getOrElse(Arr.get(sourceLines(snippet), Num.decrement(line)), () => \"\");\n return {\n start: {\n line,\n column: Option.getOrElse(Str.search(/\\S/u)(text), () => Num.decrement(FIRST_LINE)),\n },\n end: { line, column: Str.trimEnd(text).length },\n };\n});\n","import { Schema } from \"effect\";\n\nexport type DecisionModel =\n | \"typesafe/jev-latest\"\n | `typesafe/jev-${number}.${number}`\n | \"cloudflare/@cf/cloudflare/clef\"\n | \"cloudflare/@cf/cloudflare/clef-flash\"\n | \"cloudflare/@cf/cloudflare/clef-omni\";\n\nexport const JEV_MODEL = /^jev-(?:latest|\\d+\\.\\d+)$/u;\n\nexport const CLEF_MODEL = /^@cf\\/cloudflare\\/clef(?:-flash|-omni)?$/u;\n\nconst DECISION_MODEL =\n /^(?:typesafe\\/jev-(?:latest|\\d+\\.\\d+)|cloudflare\\/@cf\\/cloudflare\\/clef(?:-flash|-omni)?)$/u;\n\nconst isDecisionModel = (model: string): model is DecisionModel => DECISION_MODEL.test(model);\n\nexport const DecisionModelSchema = Schema.String.pipe(\n Schema.refine(isDecisionModel, {\n message:\n 'model must be a decision model: \"typesafe/jev-latest\", \"typesafe/jev-<major>.<minor>\", or \"cloudflare/@cf/cloudflare/clef\", \"clef-flash\" or \"clef-omni\"',\n }),\n);\n","import {\n Array as Arr,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n Record as Rec,\n pipe,\n Function as Fn,\n} from \"effect\";\n\nimport { BOOLEAN_ANSWER, decodeRuleAnswer } from \"./answer.ts\";\nimport { DecisionModelSchema } from \"./models.ts\";\nimport type { DecisionModel } from \"./models.ts\";\nimport {\n CiBehaviorSchema,\n Cutoff,\n ExplainSettingSchema,\n RuleContextSchema,\n TargetSchema,\n} from \"./schema.ts\";\nimport type {\n DecisionOptions,\n DecisionProvider,\n DecisionRule,\n ModelRef,\n ModelSpec,\n ResolvedOptions,\n ResolvedRule,\n RuleAnswer,\n} from \"./types.ts\";\n\nconst DATA_FIRST_ARITY_3 = 3;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const PREFIX = \"oxlint-plugin-decision\";\nconst PROVIDER_SEPARATOR = \"/\";\nconst ONE_RULE = 1;\n\nconst DEFAULTS = {\n ci: \"fail\",\n timeoutMs: 10_000,\n maxSnippetChars: 4000,\n model: \"cloudflare/@cf/cloudflare/clef-flash\",\n env: {},\n explain: false,\n} as const satisfies Required<DecisionOptions>;\n\nconst isSelector = (input: unknown): input is DecisionRule[\"select\"] => Predicate.isFunction(input);\n\nconst RULE_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\n\nexport const ModelSpecSchema = Schema.Union([\n DecisionModelSchema,\n Schema.NonEmptyArray(DecisionModelSchema),\n]);\n\nconst ONE = 1;\n\nconst PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(ONE));\n\nconst RuleId = Schema.NonEmptyString.check(\n Schema.isPattern(RULE_ID, { message: \"id must be lowercase words joined by hyphens\" }),\n);\n\nconst OptionsSchema = Schema.Struct({\n ci: Schema.optionalKey(CiBehaviorSchema),\n timeoutMs: Schema.optionalKey(PositiveInt),\n maxSnippetChars: Schema.optionalKey(PositiveInt),\n model: Schema.optionalKey(ModelSpecSchema),\n env: Schema.optionalKey(Schema.Record(Schema.NonEmptyString, Schema.NonEmptyString)),\n explain: Schema.optionalKey(ExplainSettingSchema),\n});\n\nconst RuleSchema = Schema.Struct({\n id: RuleId,\n target: TargetSchema,\n question: Schema.NonEmptyString,\n cutoff: Cutoff,\n message: Schema.optionalKey(Schema.NonEmptyString),\n select: Schema.optionalKey(Schema.declare(isSelector)),\n location: Schema.optionalKey(Schema.Struct({ question: Schema.NonEmptyString, cutoff: Cutoff })),\n model: Schema.optionalKey(ModelSpecSchema),\n context: Schema.optionalKey(RuleContextSchema),\n answer: Schema.optionalKey(Schema.Unknown),\n});\n\nexport const STRICT = { onExcessProperty: \"error\" } as const;\n\nconst decodeOptions = Schema.decodeUnknownResult(OptionsSchema, STRICT);\nconst decodeRule = Schema.decodeUnknownResult(RuleSchema, STRICT);\n\nconst taggedError = Schema.TaggedError;\n\nclass OptionsError extends taggedError<OptionsError, { readonly brand: unique symbol }>()(\n \"OptionsError\",\n { message: Schema.String },\n) {}\n\nexport const optionsError = (message: string): Error =>\n OptionsError.make({ message: `${PREFIX}: ${message}` });\n\nexport const modelIdsOf = (spec: ModelSpec): readonly DecisionModel[] =>\n Arr.dedupe(Arr.ensure(spec));\n\nconst splitModelId = (id: string): Option.Option<readonly [string, string]> => {\n const [provider, ...rest] = Str.split(id, PROVIDER_SEPARATOR);\n const model = pipe(rest, Arr.join(PROVIDER_SEPARATOR));\n return Option.liftPredicate(\n [provider, model] as const,\n ([left, right]) => Str.isNonEmpty(left) && Str.isNonEmpty(right),\n );\n};\n\nconst acceptedModel = (ref: ModelRef): ModelRef => {\n const { models, name } = ref.provider;\n if (!models.test(ref.model)) {\n throw optionsError(\n `model \"${ref.id}\" is not a decision model that the \"${name}\" provider accepts`,\n );\n }\n return ref;\n};\n\nexport const resolveModel: {\n (providers: Readonly<Record<string, DecisionProvider>>): (id: string) => ModelRef;\n (id: string, providers: Readonly<Record<string, DecisionProvider>>): ModelRef;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (id: string, providers: Readonly<Record<string, DecisionProvider>>): ModelRef =>\n acceptedModel(\n splitModelId(id).pipe(\n Option.flatMap(([name, model]) =>\n Option.map(Option.fromUndefinedOr(providers[name]), (provider) => ({\n id,\n provider,\n model,\n })),\n ),\n\n Option.getOrThrowWith(() =>\n optionsError(\n `model \"${id}\" must be \"<provider>/<model>\" with a provider from: ${pipe(Rec.keys(providers), Arr.join(\", \"))}`,\n ),\n ),\n ),\n ),\n);\n\nconst duplicateIdOf = (rules: readonly DecisionRule[]): Option.Option<string> =>\n Arr.findFirst(\n Rec.toEntries(Arr.groupBy(rules, ({ id }) => id)),\n ([, same]) => same.length > ONE_RULE,\n ).pipe(Option.map(([id]) => id));\n\nconst answerOf = (rule: DecisionRule): RuleAnswer => {\n if (Predicate.isUndefined(rule.answer)) {\n return BOOLEAN_ANSWER;\n }\n return Result.getOrThrowWith(decodeRuleAnswer(rule.answer), (issue) =>\n optionsError(`rule \"${rule.id}\" has an invalid answer: ${issue}`),\n );\n};\n\nexport type Decode<Value> = (input: unknown) => Result.Result<Value, Schema.SchemaError>;\n\nexport const checked: {\n (input: unknown, what: string): <Value>(decode: Decode<Value>) => Value;\n <Value>(decode: Decode<Value>, input: unknown, what: string): Value;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n <Value>(decode: Decode<Value>, input: unknown, what: string): Value =>\n Result.getOrThrowWith(decode(input), (issue) =>\n optionsError(`invalid ${what}: ${issue.message}`),\n ),\n);\n\nconst checkRule = (rule: DecisionRule): DecisionRule => {\n checked(decodeRule, rule, `rule \"${rule.id}\"`);\n if (Predicate.isNotUndefined(rule.location) && rule.target !== \"file\") {\n throw optionsError(\"location is supported only for file rules\");\n }\n answerOf(rule);\n return rule;\n};\n\nexport const checkRules = (rules: readonly DecisionRule[]): readonly DecisionRule[] => {\n if (!Arr.isReadonlyArrayNonEmpty(rules)) {\n throw optionsError(\"rules must list at least one rule\");\n }\n Option.map(duplicateIdOf(rules), (duplicate) => {\n throw optionsError(`rule id \"${duplicate}\" is used more than once`);\n });\n return pipe(\n rules,\n Arr.map((rule) => checkRule(rule)),\n );\n};\n\nconst resolveRule =\n (fallback: ModelSpec, providers: Readonly<Record<string, DecisionProvider>>) =>\n (rule: DecisionRule): ResolvedRule => ({\n ...rule,\n answer: answerOf(rule),\n models: pipe(\n modelIdsOf(rule.model ?? fallback),\n Arr.map((id) => resolveModel(id, providers)),\n ),\n });\n\nexport interface Sources {\n readonly options: DecisionOptions;\n readonly settings?: unknown;\n}\n\nconst settingsFrom = (settings: unknown): DecisionOptions => {\n if (Predicate.isUndefined(settings)) {\n return {};\n }\n return checked(decodeOptions, settings, \"settings\");\n};\n\nexport const resolveOptions: {\n (\n rules: readonly DecisionRule[],\n providers: Readonly<Record<string, DecisionProvider>>,\n ): (sources: Sources) => ResolvedOptions;\n (\n sources: Sources,\n rules: readonly DecisionRule[],\n providers: Readonly<Record<string, DecisionProvider>>,\n ): ResolvedOptions;\n} = Fn.dual(\n DATA_FIRST_ARITY_3,\n (\n { options, settings }: Sources,\n rules: readonly DecisionRule[],\n providers: Readonly<Record<string, DecisionProvider>>,\n ): ResolvedOptions => {\n const fromCode = checked(decodeOptions, options, \"createDecisionPlugin options\");\n const { model, ...merged } = { ...DEFAULTS, ...fromCode, ...settingsFrom(settings) };\n return {\n ci: merged.ci,\n timeoutMs: merged.timeoutMs,\n maxSnippetChars: merged.maxSnippetChars,\n env: merged.env,\n explain: merged.explain,\n rules: pipe(\n checkRules(rules),\n Arr.map((rule) => resolveRule(model, providers)(rule)),\n ),\n };\n },\n);\n","import {\n Array as Arr,\n Boolean as Bool,\n Number as Num,\n Option,\n Predicate,\n String as Str,\n Record as Rec,\n pipe,\n Function as Fn,\n} from \"effect\";\n\nimport { questionFor, verdictOf } from \"./answer.ts\";\nimport {\n EVERY_LINE,\n locates,\n locationCandidates,\n locationQuestion,\n numberedLines,\n validChoice,\n} from \"./location.ts\";\nimport type { ChoiceCriteria } from \"./location.ts\";\nimport type {\n Answers,\n DecisionRequest,\n DecisionResponse,\n Question,\n RequestMatch,\n Verdict,\n Verdicts,\n} from \"./types.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nconst FIRST_LINE = 1;\nconst LOCATION_SUFFIX = \"_location\";\nconst TRUNCATION_MARKER = \"/* ...truncated */\";\n\nexport const refAt = (index: number): string => `s${String(index)}`;\n\nexport const locationRefOf = (ref: string): string => `${ref}${LOCATION_SUFFIX}`;\n\nexport const snippetRefOf = (questionId: string): string =>\n Bool.match(Str.endsWith(LOCATION_SUFFIX)(questionId), {\n onTrue: () => Str.slice(Num.decrement(FIRST_LINE), -LOCATION_SUFFIX.length)(questionId),\n onFalse: () => questionId,\n });\n\nexport const truncateSnippet: {\n (maxChars: number): (text: string) => string;\n (text: string, maxChars: number): string;\n} = Fn.dual(DATA_FIRST_ARITY, (text: string, maxChars: number): string =>\n Bool.match(text.length <= maxChars, {\n onTrue: () => text,\n onFalse: () => `${Str.slice(Num.decrement(FIRST_LINE), maxChars)(text)}${TRUNCATION_MARKER}`,\n }),\n);\n\nconst numbered = (snippet: string): string =>\n pipe(\n numberedLines(snippet),\n Arr.map(({ text, line }) => `L${String(line)}| ${text}`),\n Arr.join(\"\\n\"),\n );\n\nconst contextNote = (match: RequestMatch, ref: string): string => {\n if (Predicate.isUndefined(match.context)) {\n return \"\";\n }\n return ` state.contexts.${ref} shows the source around it; use it only to understand the snippet.`;\n};\n\nconst mainQuestionFor = (match: RequestMatch, ref: string): readonly [string, Question] => [\n ref,\n questionFor(\n match.rule.answer,\n `Consider only snippet \"${ref}\" in state.snippets.${contextNote(match, ref)} ${match.rule.question}`,\n ),\n];\n\nconst questionsFor = (\n match: RequestMatch,\n ref: string,\n): readonly (readonly [string, Question])[] => {\n if (!locates(match)) {\n return [mainQuestionFor(match, ref)];\n }\n return [\n mainQuestionFor(match, ref),\n [\n locationRefOf(ref),\n locationQuestion(match, ref, locationCandidates(match.snippet, EVERY_LINE)),\n ],\n ];\n};\n\nconst snippetFor = (match: RequestMatch): string => {\n if (locates(match)) {\n return numbered(match.snippet);\n }\n return match.snippet;\n};\n\nconst contextsOf = (\n matches: readonly RequestMatch[],\n): Readonly<{ contexts?: Readonly<Record<string, string>> }> => {\n const contexts = pipe(\n matches,\n Arr.flatMap((match, index) =>\n Option.toArray(\n Option.map(Option.fromUndefinedOr(match.context), (text) => [refAt(index), text] as const),\n ),\n ),\n );\n if (Arr.isReadonlyArrayEmpty(contexts)) {\n return {};\n }\n return { contexts: Rec.fromEntries(contexts) };\n};\n\nexport const buildRequest: {\n (matches: readonly RequestMatch[]): (model: string) => DecisionRequest;\n (model: string, matches: readonly RequestMatch[]): DecisionRequest;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (model: string, matches: readonly RequestMatch[]): DecisionRequest => ({\n model,\n state: {\n snippets: Rec.fromEntries(\n pipe(\n matches,\n Arr.map((match, index) => [refAt(index), snippetFor(match)]),\n ),\n ),\n ...contextsOf(matches),\n },\n questions: Rec.fromEntries(\n pipe(\n matches,\n Arr.flatMap((match, index) => questionsFor(match, refAt(index))),\n ),\n ),\n }),\n);\n\nconst choiceQuestionsOf = (\n request: DecisionRequest,\n): readonly (readonly [string, ChoiceCriteria])[] =>\n pipe(\n Rec.toEntries(request.questions),\n Arr.flatMap(([id, question]) => {\n if (question.type === \"choice\") {\n return [[id, question.criteria] as const];\n }\n return [];\n }),\n );\n\nconst mainQuestionsOf = (request: DecisionRequest): readonly (readonly [string, Question])[] =>\n pipe(\n Rec.toEntries(request.questions),\n Arr.filter(([id]) => !Str.endsWith(LOCATION_SUFFIX)(id)),\n );\n\nconst resultOf = (\n answers: Answers,\n [ref, question]: readonly [string, Question],\n): readonly [string, Verdict] => [\n ref,\n Option.getOrThrowWith(\n verdictOf(question, answers[ref]),\n () => new Error(`response has no valid answer for \"${ref}\"`),\n ),\n];\n\nexport const parseVerdicts: {\n (request: DecisionRequest): (response: DecisionResponse) => Verdicts;\n (response: DecisionResponse, request: DecisionRequest): Verdicts;\n} = Fn.dual(DATA_FIRST_ARITY, (response: DecisionResponse, request: DecisionRequest): Verdicts => {\n const { model, answers } = Option.getOrThrowWith(\n Option.liftPredicate(response, ({ model: served }) => Str.isNonEmpty(served)),\n () => new Error(\"response has no model id\"),\n );\n const results = Rec.fromEntries(\n pipe(\n mainQuestionsOf(request),\n Arr.map((entry) => resultOf(answers, entry)),\n ),\n );\n const complete = pipe(\n choiceQuestionsOf(request),\n Arr.every(([id, criteria]) => validChoice(answers[id], criteria)),\n );\n return { model, results, answers, complete };\n});\n","import {\n Cause,\n DateTime,\n Config,\n Console,\n Effect,\n Exit,\n Option,\n Schema,\n String as Str,\n Function as Fn,\n} from \"effect\";\n\nimport { PREFIX } from \"./options.ts\";\nimport type { ResolvedOptions } from \"./types.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nconst encodeJson = Schema.encodeUnknownOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const toJson = (value: unknown): string =>\n Option.getOrElse(encodeJson(value), () => String(value));\n\nexport const nowMs = (): number => DateTime.toEpochMillis(DateTime.nowUnsafe());\n\nexport const runOrElse: {\n <Value>(\n fallback: (error: unknown) => Value,\n ): <Failure>(effect: Effect.Effect<Value, Failure>) => Value;\n <Value, Failure>(\n effect: Effect.Effect<Value, Failure>,\n fallback: (error: unknown) => Value,\n ): Value;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Failure>(\n effect: Effect.Effect<Value, Failure>,\n fallback: (error: unknown) => Value,\n ): Value =>\n Exit.match(Effect.runSyncExit(effect), {\n onSuccess: (value) => value,\n onFailure: (cause) => fallback(Cause.squash(cause)),\n }),\n);\n\nexport const envOf = (name: string): Option.Option<string> =>\n runOrElse(Config.option(Config.NonEmptyString(name)), () => Option.none()).pipe(\n Option.map((value) => Str.trim(value)),\n Option.filter(Str.isNonEmpty),\n );\n\nexport const envNameOf: {\n (name: string): (env: Readonly<Record<string, string>>) => string;\n (env: Readonly<Record<string, string>>, name: string): string;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (env: Readonly<Record<string, string>>, name: string): string => env[name] ?? name,\n);\n\nexport const failsInCi = (options: ResolvedOptions): boolean =>\n options.ci === \"fail\" && Option.isSome(envOf(\"CI\"));\n\nconst warned = new Set<string>();\n\nexport const warnOnce: {\n (message: string): (reason: string) => void;\n (reason: string, message: string): void;\n} = Fn.dual(DATA_FIRST_ARITY, (reason: string, message: string): void => {\n if (warned.has(reason)) {\n return;\n }\n warned.add(reason);\n Effect.runFork(Console.warn(`${PREFIX}: ${message}`));\n});\n\nexport const messageOf = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\nexport const captured: {\n (name: string): (match: Option.Option<RegExpMatchArray>) => Option.Option<string>;\n (match: Option.Option<RegExpMatchArray>, name: string): Option.Option<string>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (match: Option.Option<RegExpMatchArray>, name: string): Option.Option<string> =>\n match.pipe(\n Option.flatMap((found) => Option.fromNullishOr(found.groups)),\n Option.flatMap((groups) => Option.fromNullishOr(groups[name])),\n ),\n);\n","import { Array as Arr, Option, Predicate, pipe, Record as Rec } from \"effect\";\n\nimport { snippetRefOf } from \"./request.ts\";\nimport type { DecisionRequest, DecisionResponse, Question } from \"./types.ts\";\n\nconst MAX_QUESTIONS = 64;\n\ntype State = DecisionRequest[\"state\"];\n\nexport interface WireRequest extends Readonly<Pick<DecisionRequest, \"model\" | \"state\">> {\n readonly questions: Readonly<Record<string, Question>>;\n}\n\nconst only = (\n entries: Readonly<Record<string, string>>,\n ref: string,\n): Readonly<Record<string, string>> =>\n Option.match(Option.fromUndefinedOr(entries[ref]), {\n onNone: () => ({}),\n onSome: (text) => ({ [ref]: text }),\n });\n\nconst stateOf = ({ snippets, contexts }: State, ref: string): State => {\n if (Predicate.isUndefined(contexts)) {\n return { snippets: only(snippets, ref) };\n }\n return { snippets: only(snippets, ref), contexts: only(contexts, ref) };\n};\n\nexport const fileRequestsFor = (\n request: DecisionRequest,\n): Arr.NonEmptyReadonlyArray<WireRequest> => {\n const wires = pipe(\n Arr.chunksOf(Rec.toEntries(request.questions), MAX_QUESTIONS),\n Arr.map((chunk): WireRequest => ({ ...request, questions: Rec.fromEntries(chunk) })),\n );\n if (Arr.isReadonlyArrayNonEmpty(wires)) {\n return wires;\n }\n return [request];\n};\n\nexport const snippetRequestsFor = (\n request: DecisionRequest,\n): Arr.NonEmptyReadonlyArray<WireRequest> => {\n const bySnippet = Arr.groupBy(Rec.toEntries(request.questions), ([id]) => snippetRefOf(id));\n const wires = pipe(\n Rec.toEntries(bySnippet),\n Arr.flatMap(([ref, questions]) =>\n pipe(\n Arr.chunksOf(questions, MAX_QUESTIONS),\n Arr.map((chunk): WireRequest => ({\n model: request.model,\n state: stateOf(request.state, ref),\n questions: Rec.fromEntries(chunk),\n })),\n ),\n ),\n );\n if (Arr.isReadonlyArrayNonEmpty(wires)) {\n return wires;\n }\n return [request];\n};\n\nexport const mergeResponses = (\n responses: Arr.NonEmptyReadonlyArray<DecisionResponse>,\n): DecisionResponse => ({\n model: Arr.headNonEmpty(responses).model,\n answers: pipe(\n responses,\n Arr.flatMap(({ answers }) => Rec.toEntries(answers)),\n Rec.fromEntries,\n ),\n});\n"],"mappings":";;AAEA,MAAM,OAAO;AACb,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB,OAAO,IAAI,MAAM,OAAO,uBAAuB,IAAI,CAAC;AAE3E,MAAa,cAAc,OAAO,OAAO,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAAE,CAAC,CAAC;AAE3F,MAAa,YAAY;AAEzB,MAAa,SAAS,OAAO,OAAO,MAClC,OAAO,UACL;CAA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