@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.
Files changed (50) hide show
  1. package/README.md +17 -3
  2. package/dist/{app-Bso1uwY5.mjs → app-D2bguKZ_.mjs} +182 -88
  3. package/dist/app-D2bguKZ_.mjs.map +1 -0
  4. package/dist/claim-rule-B0LCcxxc.mjs +36 -0
  5. package/dist/claim-rule-B0LCcxxc.mjs.map +1 -0
  6. package/dist/cloudflare-worker.mjs +111 -3
  7. package/dist/cloudflare-worker.mjs.map +1 -1
  8. package/dist/{index-BOrpK3Iv.d.mts → index-B4wX62VC.d.mts} +2 -2
  9. package/dist/{index-Cgg-w0hb.d.mts → index-CK88FBE5.d.mts} +691 -349
  10. package/dist/index.d.mts +2 -3
  11. package/dist/index.mjs +1 -1
  12. package/dist/{define-presets-clyqLZxo.mjs → preset-plugin-MKdvpXxa.mjs} +11 -214
  13. package/dist/preset-plugin-MKdvpXxa.mjs.map +1 -0
  14. package/dist/presets/ai-slop.d.mts +2 -3
  15. package/dist/presets/ai-slop.mjs +179 -2
  16. package/dist/presets/ai-slop.mjs.map +1 -1
  17. package/dist/presets/index.d.mts +1 -1
  18. package/dist/presets/index.mjs +1 -1
  19. package/dist/presets/recommended.d.mts +1 -2
  20. package/dist/presets/recommended.mjs +1 -2
  21. package/dist/presets/recommended.mjs.map +1 -1
  22. package/dist/presets/review-only.d.mts +1 -2
  23. package/dist/presets/review-only.mjs +1 -2
  24. package/dist/presets/review-only.mjs.map +1 -1
  25. package/dist/presets/strict.d.mts +1 -2
  26. package/dist/presets/strict.mjs +1 -2
  27. package/dist/presets/strict.mjs.map +1 -1
  28. package/dist/serve-decisions-D6M-l2uy.mjs +232 -0
  29. package/dist/serve-decisions-D6M-l2uy.mjs.map +1 -0
  30. package/dist/typesafe-worker.mjs +29 -0
  31. package/dist/typesafe-worker.mjs.map +1 -0
  32. package/dist/{decision-BtTZ52be.mjs → wire-CKpt_MBX.mjs} +56 -261
  33. package/dist/wire-CKpt_MBX.mjs.map +1 -0
  34. package/package.json +26 -29
  35. package/skills/write-decision-rules/SKILL.md +6 -7
  36. package/skills/write-decision-rules/references/tuning.md +3 -5
  37. package/dist/app-Bso1uwY5.mjs.map +0 -1
  38. package/dist/decision-BtTZ52be.mjs.map +0 -1
  39. package/dist/define-presets-clyqLZxo.mjs.map +0 -1
  40. package/dist/index-D7VrRpTx.d.mts +0 -6
  41. package/dist/openrouter-app.d.mts +0 -19
  42. package/dist/openrouter-app.mjs +0 -1
  43. package/dist/openrouter-worker.mjs +0 -15
  44. package/dist/openrouter-worker.mjs.map +0 -1
  45. package/dist/preset-plugin-AAwedMeS.mjs +0 -10
  46. package/dist/preset-plugin-AAwedMeS.mjs.map +0 -1
  47. package/dist/serve-decisions-CjlhvYm7.mjs +0 -290
  48. package/dist/serve-decisions-CjlhvYm7.mjs.map +0 -1
  49. package/skills/write-decision-rules/references/providers.md +0 -55
  50. /package/dist/{openrouter-worker.d.mts → typesafe-worker.d.mts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ai-slop.mjs","names":[],"sources":["../../src/app/ai-slop.ts"],"sourcesContent":["import { createDecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { aiSlopRules } from \"#/features/define-presets/index.ts\";\n\nconst plugin: DecisionPlugin = createDecisionPlugin({\n name: \"decision-ai-slop\",\n rules: aiSlopRules,\n});\n\nexport default plugin;\nexport {\n aiSlopRules,\n castInsteadOfNarrowing,\n commentNarratesHistory,\n commentRestatesCode,\n defaultMasksMissingValue,\n docRestatesSignature,\n passThroughWrapper,\n placeholderImplementation,\n redundantGuard,\n reinventsBuiltin,\n suppressionInsteadOfFix,\n} from \"#/features/define-presets/index.ts\";\n"],"mappings":";;;AAKA,MAAM,SAAyB,qBAAqB;CAClD,MAAM;CACN,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"ai-slop.mjs","names":["Arr","Arr","Str"],"sources":["../../src/features/define-presets/lib/ai-slop-select.ts","../../src/features/define-presets/lib/comment-select.ts","../../src/features/define-presets/model/ai-slop-rules.ts","../../src/app/ai-slop.ts"],"sourcesContent":["import { Array as Arr, Match, Option, Predicate, pipe } from \"effect\";\n\nimport type { SelectedNode } from \"#/entities/decision/index.ts\";\n\nimport { containing, dualSelect, identifierOf, ofType } from \"./select.ts\";\nimport type { DualSelect, NodeTest } from \"./select.ts\";\n\nconst isPlaceholderValue = ofType(\n \"Literal\",\n \"TemplateLiteral\",\n \"ArrayExpression\",\n \"ObjectExpression\",\n);\n\nconst isFallbackOperator: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"LogicalExpression\", operator: \"??\" }, () => true),\n Match.when({ type: \"LogicalExpression\", operator: \"||\" }, (logical) =>\n isPlaceholderValue(logical.right),\n ),\n Match.when({ type: \"AssignmentExpression\", operator: \"??=\" }, () => true),\n Match.when({ type: \"AssignmentExpression\", operator: \"||=\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst isTypeofCheck: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"UnaryExpression\", operator: \"typeof\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst isConstAssertion = (annotation: SelectedNode): boolean =>\n Match.value(annotation).pipe(\n Match.when(\n { type: \"TSTypeReference\", typeName: { type: \"Identifier\", name: \"const\" } },\n () => true,\n ),\n Match.orElse(() => false),\n );\n\nconst isCast: NodeTest = (node) =>\n Match.value(node).pipe(\n Match.when({ type: \"TSAsExpression\" }, (cast) => !isConstAssertion(cast.typeAnnotation)),\n Match.when({ type: \"TSTypeAssertion\" }, () => true),\n Match.when({ type: \"TSNonNullExpression\" }, () => true),\n Match.orElse(() => false),\n );\n\nconst bodyOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(node).pipe(\n Match.when({ type: \"FunctionDeclaration\" }, (fn) => Option.fromNullishOr(fn.body)),\n Match.when({ type: \"FunctionExpression\" }, (fn) => Option.fromNullishOr(fn.body)),\n Match.when({ type: \"ArrowFunctionExpression\" }, (fn) => Option.some(fn.body)),\n Match.orElse(() => Option.none()),\n );\n\nconst statementsOf = (body: SelectedNode): readonly SelectedNode[] =>\n Match.value(body).pipe(\n Match.when({ type: \"BlockStatement\" }, (block) => block.body),\n Match.orElse((expression) => [expression]),\n );\n\nconst ONE_STATEMENT = 1;\n\nconst isCall = ofType(\"CallExpression\", \"NewExpression\");\n\nconst parentOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.fromNullishOr(node.parent);\n\nconst isArgument = (node: SelectedNode): boolean => Option.exists(parentOf(node), isCall);\n\nconst isOptionOfCall = (node: SelectedNode): boolean =>\n parentOf(node).pipe(\n Option.filter(ofType(\"Property\")),\n Option.flatMap(parentOf),\n Option.filter(ofType(\"ObjectExpression\")),\n Option.exists(isArgument),\n );\n\nconst isCallback: NodeTest = Predicate.or(isArgument, isOptionOfCall);\n\nexport const isDeclared: NodeTest = Predicate.not(isCallback);\n\nconst isShort: NodeTest = (node) =>\n Option.exists(bodyOf(node), (body) => statementsOf(body).length <= ONE_STATEMENT);\n\nconst hasAtMostOneStatement: NodeTest = Predicate.and(isDeclared, isShort);\n\nconst expressionOf = (statement: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(statement).pipe(\n Match.when({ type: \"ReturnStatement\" }, (returned) => Option.fromNullishOr(returned.argument)),\n Match.when({ type: \"ExpressionStatement\" }, (expression) => Option.some(expression.expression)),\n Match.orElse((other) => Option.some(other)),\n );\n\nconst awaitedOf = (expression: SelectedNode): SelectedNode =>\n Match.value(expression).pipe(\n Match.when({ type: \"AwaitExpression\" }, (awaited) => awaited.argument),\n Match.orElse((plain) => plain),\n );\n\nconst isForwardingStatement = (statements: readonly SelectedNode[]): boolean =>\n Option.exists(\n Option.flatMap(Arr.head(statements), expressionOf),\n (expression) => awaitedOf(expression).type === \"CallExpression\",\n );\n\nconst isSingleCall: NodeTest = (node) =>\n Option.exists(bodyOf(node), (body) => isForwardingStatement(statementsOf(body)));\n\nconst paramsOf = (node: SelectedNode): readonly SelectedNode[] =>\n Match.value(node).pipe(\n Match.when({ type: \"FunctionDeclaration\" }, (fn) => fn.params),\n Match.when({ type: \"FunctionExpression\" }, (fn) => fn.params),\n Match.when({ type: \"ArrowFunctionExpression\" }, (fn) => fn.params),\n Match.orElse(() => []),\n );\n\nconst nameOf = (node: SelectedNode): Option.Option<string> =>\n Match.value(node).pipe(\n Match.when({ type: \"SpreadElement\" }, (spread) => identifierOf(spread.argument)),\n Match.when({ type: \"RestElement\" }, (rest) => identifierOf(rest.argument)),\n Match.orElse((plain) => identifierOf(plain)),\n );\n\nconst argumentsOf = (node: SelectedNode): Option.Option<readonly SelectedNode[]> =>\n bodyOf(node).pipe(\n Option.flatMap((body) => Arr.head(statementsOf(body))),\n Option.flatMap(expressionOf),\n Option.map(awaitedOf),\n Option.flatMap((expression) =>\n Match.value(expression).pipe(\n Match.when({ type: \"CallExpression\" }, (call) => Option.some(call.arguments)),\n Match.orElse(() => Option.none()),\n ),\n ),\n );\n\nconst isForwardedArgument =\n (names: readonly string[]) =>\n (argument: SelectedNode): boolean =>\n Match.value(argument).pipe(\n Match.when({ type: \"Literal\" }, () => true),\n Match.orElse((other) => Option.exists(nameOf(other), (name) => names.includes(name))),\n );\n\nconst passesExactly = (names: readonly string[]): Predicate.Predicate<readonly SelectedNode[]> =>\n Predicate.and(\n (passed) =>\n pipe(\n passed,\n Arr.every((argument) => isForwardedArgument(names)(argument)),\n ),\n (passed) => {\n const passedNames = Arr.getSomes(\n pipe(\n passed,\n Arr.map((argument) => nameOf(argument)),\n ),\n );\n return pipe(\n names,\n Arr.every((name) => passedNames.includes(name)),\n );\n },\n );\n\nconst passesParamsUnchanged: NodeTest = (node) =>\n pipe(\n paramsOf(node),\n Arr.map((param) => nameOf(param)),\n Option.all,\n Option.exists((names) => Option.exists(argumentsOf(node), passesExactly(names))),\n );\n\nexport const forwardsOneCall: NodeTest = Predicate.and(\n Predicate.and(hasAtMostOneStatement, isSingleCall),\n passesParamsUnchanged,\n);\n\nconst declaredTypeOf = (param: SelectedNode): Option.Option<SelectedNode> =>\n Match.value(param).pipe(\n Match.when({ type: \"AssignmentPattern\" }, (assigned) => declaredTypeOf(assigned.left)),\n Match.when({ type: \"TSParameterProperty\" }, (property) => declaredTypeOf(property.parameter)),\n Match.when({ typeAnnotation: { type: \"TSTypeAnnotation\" } }, (typed) =>\n Option.some(typed.typeAnnotation.typeAnnotation),\n ),\n Match.orElse(() => Option.none()),\n );\n\nconst isOpenType = ofType(\"TSUnknownKeyword\", \"TSAnyKeyword\");\n\nconst hasNarrowParameter: NodeTest = (node) =>\n pipe(\n paramsOf(node),\n Arr.some((param) => Option.exists(declaredTypeOf(param), Predicate.not(isOpenType))),\n );\n\nconst typeParameterNamesOf = (node: SelectedNode): readonly string[] =>\n Match.value(node).pipe(\n Match.when({ typeParameters: { type: \"TSTypeParameterDeclaration\" } }, (generic) =>\n pipe(\n generic.typeParameters.params,\n Arr.map((parameter) => parameter.name.name),\n ),\n ),\n Match.orElse(() => []),\n );\n\nconst referencedNameOf = (type: SelectedNode): Option.Option<string> =>\n Match.value(type).pipe(\n Match.when({ type: \"TSTypeReference\", typeName: { type: \"Identifier\" } }, (reference) =>\n Option.some(reference.typeName.name),\n ),\n Match.orElse(() => Option.none()),\n );\n\nconst isGenericParameter = (node: SelectedNode, param: SelectedNode): boolean =>\n Option.exists(Option.flatMap(declaredTypeOf(param), referencedNameOf), (name) =>\n typeParameterNamesOf(node).includes(name),\n );\n\nconst returnedOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.flatMap(bodyOf(node), (body) =>\n Option.flatMap(Arr.head(statementsOf(body)), expressionOf),\n );\n\nconst returnedNameOf = (node: SelectedNode): Option.Option<string> =>\n Option.flatMap(returnedOf(node), identifierOf);\n\nconst returnsParameter = (node: SelectedNode, param: SelectedNode): boolean =>\n Option.exists(\n Option.all([returnedNameOf(node), identifierOf(param)]),\n ([returned, given]) => returned === given,\n );\n\nconst ONE_PARAMETER = 1;\n\nconst onlyParameterOf = (node: SelectedNode): Option.Option<SelectedNode> =>\n Option.liftPredicate(paramsOf(node), (params) => params.length === ONE_PARAMETER).pipe(\n Option.flatMap(Arr.head),\n );\n\nconst isGenericIdentity: NodeTest = (node) =>\n onlyParameterOf(node).pipe(\n Option.filter((param) => isGenericParameter(node, param)),\n Option.exists((param) => returnsParameter(node, param)),\n );\n\nexport const mayBePlaceholder: NodeTest = Predicate.and(\n hasAtMostOneStatement,\n Predicate.not(isGenericIdentity),\n);\n\nconst isGuard: NodeTest = Predicate.or(\n ofType(\"IfStatement\", \"ConditionalExpression\", \"ChainExpression\", \"TryStatement\"),\n isTypeofCheck,\n);\n\nexport const hasGuard: NodeTest = Predicate.and(hasNarrowParameter, containing(isGuard));\n\nconst isFallback: NodeTest = Predicate.or(isFallbackOperator, ofType(\"AssignmentPattern\"));\n\nexport const hasFallback: DualSelect = dualSelect(containing(isFallback));\n\nexport const hasCast: DualSelect = dualSelect(containing(isCast));\n","import { Array as Arr, String as Str, pipe } from \"effect\";\n\nimport type { SelectMatch, SelectedNode } from \"#/entities/decision/index.ts\";\n\nimport { dualSelect } from \"./select.ts\";\nimport type { DualSelect } from \"./select.ts\";\n\nconst commentsIn = (node: SelectedNode, { context }: SelectMatch): readonly string[] => {\n const [start, end] = node.range;\n return pipe(\n context.sourceCode.getAllComments(),\n Arr.filter((comment) => comment.start >= start && comment.end <= end),\n Arr.map((comment) => comment.value),\n );\n};\n\nexport const hasCommentInside: DualSelect = dualSelect((node, match) =>\n Arr.isReadonlyArrayNonEmpty(commentsIn(node, match)),\n);\n\nconst SUPPRESSIONS = [\n \"eslint-disable\",\n \"oxlint-disable\",\n \"@ts-ignore\",\n \"@ts-expect-error\",\n \"@ts-nocheck\",\n \"fallow-ignore\",\n];\n\nexport const hasSuppression: DualSelect = dualSelect((node, match) =>\n pipe(\n commentsIn(node, match),\n Arr.some((comment) =>\n pipe(\n SUPPRESSIONS,\n Arr.some((word) => Str.includes(word)(comment)),\n ),\n ),\n ),\n);\n","import type { DecisionRule } from \"#/entities/decision/index.ts\";\nimport {\n forwardsOneCall,\n isDeclared,\n mayBePlaceholder,\n hasCast,\n hasFallback,\n hasGuard,\n} from \"#/features/define-presets/lib/ai-slop-select.ts\";\nimport type { ClaimRule } from \"#/features/define-presets/lib/claim-rule.ts\";\nimport { claimRule } from \"#/features/define-presets/lib/claim-rule.ts\";\nimport { hasCommentInside, hasSuppression } from \"#/features/define-presets/lib/comment-select.ts\";\n\nconst CUTOFF = 0.8;\n\nconst slopRule = (rule: Omit<ClaimRule, \"cutoff\">): DecisionRule =>\n claimRule({ cutoff: CUTOFF, ...rule });\n\nexport const redundantGuard = slopRule({\n id: \"redundant-guard\",\n select: hasGuard,\n ask: \"This function checks one of its own parameters for a case that the parameter's declared type already rules out, so the check can never change what happens.\",\n yes: \"A parameter whose type annotation is non-optional and non-nullable, such as `user: User` or `name: string`, is compared with null or undefined, has its `typeof` tested against the type it is already declared as, or is read with `?.`.\",\n no: \"No parameter is checked against its own declared type. Checks on local variables do not count: a local that holds the result of `Map.get`, `find`, `JSON.parse` or any other call, or a value annotated `unknown`, can really be missing or of another type, so checking it is necessary. Parameters of plain JavaScript have no declared type, so any check on them is allowed.\",\n});\n\nexport const defaultMasksMissingValue = slopRule({\n id: \"default-masks-missing-value\",\n select: hasFallback,\n ask: \"This function replaces a value that should always be present with a made-up default, so a missing value is hidden instead of reported.\",\n yes: \"A `??` or `||` default, or a default parameter, stands in for data the rest of the code treats as required, such as an id, a user, a price, a config entry or a response field, with a placeholder like 'unknown', '', 0, [] or {} that later code will use as if it were real; or a chain of two or more fallbacks (`a ?? b ?? c`) picks among sources with no sign of why that order is right.\",\n no: \"Every default is a value the domain genuinely allows when the input is absent, such as an optional setting with a documented default, an empty list for an optional filter, or a display label for an optional field; or the missing case is reported, thrown or returned to the caller instead of being filled in.\",\n});\n\nexport const passThroughWrapper = slopRule({\n id: \"pass-through-wrapper\",\n select: forwardsOneCall,\n ask: \"This function only forwards its arguments to another function and returns the result, adding no behaviour of its own.\",\n yes: \"The body is a single call that receives every parameter exactly as it came in, in the same order, or with an extra argument that is always the same constant, and returns or awaits the result unchanged, so callers could call the inner function directly.\",\n no: \"The function changes something on the way: it transforms an argument before passing it on (for example trimming, lower-casing, converting or validating it), transforms the result, binds a dependency, adapts to a different signature a caller requires, or it is an entry point that a framework or another package calls by name.\",\n});\n\nexport const placeholderImplementation = slopRule({\n id: \"placeholder-implementation\",\n select: mayBePlaceholder,\n ask: \"This function is a stand-in that pretends to do its job: it returns a fixed value or does nothing where its name promises real work.\",\n yes: \"The body is empty, only logs, or only holds a TODO while the name promises an action; a validator, checker or permission function always returns true or always returns false; a function named after a computation returns a hard-coded number, string or object; or a branch the name promises to handle silently does nothing.\",\n no: \"The body does the work its name promises, even simply. An intentional no-op whose name says so (noop, ignore, a default callback), an abstract method meant to be overridden, and a test double inside test code are not placeholders.\",\n});\n\nexport const commentRestatesCode = slopRule({\n id: \"comment-restates-code\",\n select: hasCommentInside,\n ask: \"A comment inside this function only translates the next line of code into words and adds no reason, unit, or constraint.\",\n yes: \"A comment repeats the code in words, such as `// increment the counter` over `count += 1`, `// loop over the items` over a for loop, or `// return the total` over a return; deleting it would leave a reader knowing exactly as much.\",\n no: \"Every comment says something the code cannot say on its own: why it is done this way (often with `because` or `so`), a fact about the outside world such as a billing rule, an API quirk or a standard, a unit, or an invariant. Lint directive comments such as `eslint-disable` are not judged here.\",\n});\n\nexport const commentNarratesHistory = slopRule({\n id: \"comment-narrates-history\",\n select: hasCommentInside,\n ask: \"A comment inside this function records how the code came to be, or speaks to the person who asked for the change, instead of describing the code as it stands.\",\n yes: \"A comment says what was added, changed, removed, fixed or kept for compatibility (`added X`, `changed to Y`, `previously`, `now uses`, `new:`), marks the code as a stopgap (`temporary`, `for now`, `quick fix`, `hack until`), mentions a date, a ticket in progress, a model or a conversation, or addresses a reader as if replying (`as requested`, `here we`, `note that I`).\",\n no: \"Every comment describes the code as it is now and would still be true and useful to a reader who never saw the earlier version or the conversation. A TODO that names a concrete missing case is a description of the code, not history.\",\n});\n\nexport const docRestatesSignature = slopRule({\n id: \"doc-restates-signature\",\n context: { scope: \"comment\" },\n ask: \"The comment above this function contains nothing except the function's name and parameter names reworded.\",\n yes: \"Every sentence of the comment can be rebuilt from the signature alone, such as `Gets the order.`, `@param id - the id`, `@returns the order` or `Creates a new instance.`\",\n no: \"At least one sentence states behaviour the signature does not show, such as what is returned when nothing matches, when it fails, a unit or range, a side effect, or how values are compared.\",\n});\n\nexport const castInsteadOfNarrowing = slopRule({\n id: \"cast-instead-of-narrowing\",\n select: hasCast,\n ask: \"This function uses a type assertion (`as`, `<T>` or a non-null `!`) to silence the type checker where the value is not known to have that type.\",\n yes: \"The asserted type is not established by anything on the path: data from parsing, I/O, `unknown`, `any` or a wider union is cast to a specific shape without a check, a possibly missing value gets `!` without a preceding check or a guarantee from the API, or the cast goes through `unknown` (`as unknown as T`) to force an unrelated type.\",\n no: \"Each assertion states something the code has just established or the API guarantees, such as a cast after a type guard, a DOM element looked up by a selector that the same module creates, or a literal narrowed for an overload; `as const` is not a cast.\",\n});\n\nexport const suppressionInsteadOfFix = slopRule({\n id: \"suppression-instead-of-fix\",\n select: hasSuppression,\n ask: \"A lint or type-check suppression comment inside this function hides a problem that the code next to it could simply fix.\",\n yes: \"The directive gives no reason after the rule name, or the line it silences has a direct local fix, such as handling a floating promise, typing a value instead of `any`, removing an unused variable, or narrowing instead of `@ts-ignore`.\",\n no: \"Every directive is followed by `--` or a comment with a reason explaining why the rule does not fit this line, such as output a command-line tool prints on purpose, a wrong third-party type, or generated code.\",\n});\n\nexport const reinventsBuiltin = slopRule({\n id: \"reinvents-builtin\",\n select: isDeclared,\n ask: \"This function contains a hand-written loop or algorithm that re-implements something the JavaScript standard library or the platform already provides.\",\n yes: \"A loop or manual algorithm in the body does what one built-in call does: de-duplicating with an array and includes instead of a Set, deep copying instead of structuredClone, grouping instead of Object.groupBy, building query strings instead of URLSearchParams, formatting numbers or dates instead of Intl, padding instead of padStart, flattening instead of flat, or finding the last match instead of findLast.\",\n no: \"The function has no such hand-written loop: it already calls the built-in directly (for example `new Set`, `structuredClone`, `reduce` or `Intl`), or its loop does domain work that no single built-in does. A chain of built-in array methods such as `filter`, `map`, `flatMap` and `flat` already uses the built-ins.\",\n});\n\nexport const aiSlopRules = [\n redundantGuard,\n defaultMasksMissingValue,\n passThroughWrapper,\n placeholderImplementation,\n commentRestatesCode,\n commentNarratesHistory,\n docRestatesSignature,\n castInsteadOfNarrowing,\n suppressionInsteadOfFix,\n reinventsBuiltin,\n] as const;\n","import { createDecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\nimport type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { aiSlopRules } from \"#/features/define-presets/index.ts\";\n\nconst plugin: DecisionPlugin = createDecisionPlugin({\n name: \"decision-ai-slop\",\n rules: aiSlopRules,\n});\n\nexport default plugin;\nexport {\n aiSlopRules,\n castInsteadOfNarrowing,\n commentNarratesHistory,\n commentRestatesCode,\n defaultMasksMissingValue,\n docRestatesSignature,\n passThroughWrapper,\n placeholderImplementation,\n redundantGuard,\n reinventsBuiltin,\n suppressionInsteadOfFix,\n} from \"#/features/define-presets/index.ts\";\n"],"mappings":";;;;AAOA,MAAM,qBAAqB,OACzB,WACA,mBACA,mBACA,kBACF;AAEA,MAAM,sBAAgC,SACpC,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK;CAAE,MAAM;CAAqB,UAAU;AAAK,SAAS,IAAI,GACpE,MAAM,KAAK;CAAE,MAAM;CAAqB,UAAU;AAAK,IAAI,YACzD,mBAAmB,QAAQ,KAAK,CAClC,GACA,MAAM,KAAK;CAAE,MAAM;CAAwB,UAAU;AAAM,SAAS,IAAI,GACxE,MAAM,KAAK;CAAE,MAAM;CAAwB,UAAU;AAAM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ACJ,SAAS,EAAE,OAAO,UAAU;CAC5B,KAAK;CACL,KAAK;CACL,IAAI;AACN,CAAC;AAED,MAAa,yBAAyB,SAAS;CAC7C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,KAAK;CACL,IAAI;AACN,CAAC;AAED,MAAa,0BAA0B,SAAS;CAC9C,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,KAAK;CACL,IAAI;AACN,CAAC;AAED,MAAa,mBAAmB,SAAS;CACvC,IAAI;CACJ,QAAQ;CACR,KAAK;CACL,KAAK;CACL,IAAI;AACN,CAAC;AAED,MAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;ACxGA,MAAM,SAAyB,qBAAqB;CAClD,MAAM;CACN,OAAO;AACT,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import plugin from "./recommended.mjs";
2
- import { A as safeNameIsSafe, C as docErrorsMatchBody, D as logLevelMatchesEvent, E as idempotentName, O as logMessageMatchesEvent, S as commentDescribesDeclaration, T as fnNamePromises, _ as reviewOnly, a as testNameDescribesCode, b as codeClaims, c as nameMatchesBehavior, d as noPromptInjection, f as preferSchemaValidation, g as recommended, h as presets, i as testMocksSubject, j as varNameDescribesValue, k as pureNameIsPure, l as noHardcodedSecrets, m as Preset, n as snapshotOnlyBehaviourClaim, o as testNameVerifiesClaim, p as untrustedInputRisk, r as testClaims, s as domainNaming, t as describeNamesSubject, u as noPiiInLogs, v as strict, w as errorMessageMatchesCondition, x as commentDescribesBlock, y as catchHidesFailure } from "../index-BOrpK3Iv.mjs";
2
+ import { A as safeNameIsSafe, C as docErrorsMatchBody, D as logLevelMatchesEvent, E as idempotentName, O as logMessageMatchesEvent, S as commentDescribesDeclaration, T as fnNamePromises, _ as reviewOnly, a as testNameDescribesCode, b as codeClaims, c as nameMatchesBehavior, d as noPromptInjection, f as preferSchemaValidation, g as recommended, h as presets, i as testMocksSubject, j as varNameDescribesValue, k as pureNameIsPure, l as noHardcodedSecrets, m as Preset, n as snapshotOnlyBehaviourClaim, o as testNameVerifiesClaim, p as untrustedInputRisk, r as testClaims, s as domainNaming, t as describeNamesSubject, u as noPiiInLogs, v as strict, w as errorMessageMatchesCondition, x as commentDescribesBlock, y as catchHidesFailure } from "../index-B4wX62VC.mjs";
3
3
  export { type Preset, catchHidesFailure, codeClaims, commentDescribesBlock, commentDescribesDeclaration, plugin as default, describeNamesSubject, docErrorsMatchBody, domainNaming, errorMessageMatchesCondition, fnNamePromises, idempotentName, logLevelMatchesEvent, logMessageMatchesEvent, nameMatchesBehavior, noHardcodedSecrets, noPiiInLogs, noPromptInjection, preferSchemaValidation, presets, pureNameIsPure, recommended, reviewOnly, safeNameIsSafe, snapshotOnlyBehaviourClaim, strict, testClaims, testMocksSubject, testNameDescribesCode, testNameVerifiesClaim, untrustedInputRisk, varNameDescribesValue };
@@ -1,3 +1,3 @@
1
1
  import plugin from "./recommended.mjs";
2
- import { A as varNameDescribesValue, C as errorMessageMatchesCondition, D as logMessageMatchesEvent, E as logLevelMatchesEvent, O as pureNameIsPure, S as docErrorsMatchBody, T as idempotentName, _ as untrustedInputRisk, a as describeNamesSubject, b as commentDescribesBlock, c as testMocksSubject, d as domainNaming, f as nameMatchesBehavior, g as preferSchemaValidation, h as noPromptInjection, i as strict, k as safeNameIsSafe, l as testNameDescribesCode, m as noPiiInLogs, n as recommended, o as snapshotOnlyBehaviourClaim, p as noHardcodedSecrets, r as reviewOnly, s as testClaims, t as presets, u as testNameVerifiesClaim, v as catchHidesFailure, w as fnNamePromises, x as commentDescribesDeclaration, y as codeClaims } from "../define-presets-clyqLZxo.mjs";
2
+ import { A as safeNameIsSafe, C as docErrorsMatchBody, D as logLevelMatchesEvent, E as idempotentName, O as logMessageMatchesEvent, S as commentDescribesDeclaration, T as fnNamePromises, _ as preferSchemaValidation, a as strict, b as codeClaims, c as testClaims, d as testNameVerifiesClaim, f as domainNaming, g as noPromptInjection, h as noPiiInLogs, i as reviewOnly, j as varNameDescribesValue, k as pureNameIsPure, l as testMocksSubject, m as noHardcodedSecrets, n as presets, o as describeNamesSubject, p as nameMatchesBehavior, r as recommended, s as snapshotOnlyBehaviourClaim, u as testNameDescribesCode, v as untrustedInputRisk, w as errorMessageMatchesCondition, x as commentDescribesBlock, y as catchHidesFailure } from "../preset-plugin-MKdvpXxa.mjs";
3
3
  export { catchHidesFailure, codeClaims, commentDescribesBlock, commentDescribesDeclaration, plugin as default, describeNamesSubject, docErrorsMatchBody, domainNaming, errorMessageMatchesCondition, fnNamePromises, idempotentName, logLevelMatchesEvent, logMessageMatchesEvent, nameMatchesBehavior, noHardcodedSecrets, noPiiInLogs, noPromptInjection, preferSchemaValidation, presets, pureNameIsPure, recommended, reviewOnly, safeNameIsSafe, snapshotOnlyBehaviourClaim, strict, testClaims, testMocksSubject, testNameDescribesCode, testNameVerifiesClaim, untrustedInputRisk, varNameDescribesValue };
@@ -1,5 +1,4 @@
1
- import { c as DecisionPlugin } from "../index-Cgg-w0hb.mjs";
2
- import "../index-D7VrRpTx.mjs";
1
+ import { o as DecisionPlugin } from "../index-CK88FBE5.mjs";
3
2
  declare const plugin: DecisionPlugin;
4
3
  export { plugin as default };
5
4
  //# sourceMappingURL=recommended.d.mts.map
@@ -1,5 +1,4 @@
1
- import { n as recommended } from "../define-presets-clyqLZxo.mjs";
2
- import { t as presetPlugin } from "../preset-plugin-AAwedMeS.mjs";
1
+ import { r as recommended, t as presetPlugin } from "../preset-plugin-MKdvpXxa.mjs";
3
2
  // src/app/recommended.ts
4
3
  const plugin = presetPlugin(recommended);
5
4
  export { plugin as default };
@@ -1 +1 @@
1
- {"version":3,"file":"recommended.mjs","names":[],"sources":["../../src/app/recommended.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { recommended } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(recommended);\n\nexport default plugin;\n"],"mappings":";;;AAMA,MAAM,SAAyB,aAAa,WAAW"}
1
+ {"version":3,"file":"recommended.mjs","names":[],"sources":["../../src/app/recommended.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { recommended } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(recommended);\n\nexport default plugin;\n"],"mappings":";;AAMA,MAAM,SAAyB,aAAa,WAAW"}
@@ -1,5 +1,4 @@
1
- import { c as DecisionPlugin } from "../index-Cgg-w0hb.mjs";
2
- import "../index-D7VrRpTx.mjs";
1
+ import { o as DecisionPlugin } from "../index-CK88FBE5.mjs";
3
2
  declare const plugin: DecisionPlugin;
4
3
  export { plugin as default };
5
4
  //# sourceMappingURL=review-only.d.mts.map
@@ -1,5 +1,4 @@
1
- import { r as reviewOnly } from "../define-presets-clyqLZxo.mjs";
2
- import { t as presetPlugin } from "../preset-plugin-AAwedMeS.mjs";
1
+ import { i as reviewOnly, t as presetPlugin } from "../preset-plugin-MKdvpXxa.mjs";
3
2
  // src/app/review-only.ts
4
3
  const plugin = presetPlugin(reviewOnly);
5
4
  export { plugin as default };
@@ -1 +1 @@
1
- {"version":3,"file":"review-only.mjs","names":[],"sources":["../../src/app/review-only.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { reviewOnly } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(reviewOnly);\n\nexport default plugin;\n"],"mappings":";;;AAMA,MAAM,SAAyB,aAAa,UAAU"}
1
+ {"version":3,"file":"review-only.mjs","names":[],"sources":["../../src/app/review-only.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { reviewOnly } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(reviewOnly);\n\nexport default plugin;\n"],"mappings":";;AAMA,MAAM,SAAyB,aAAa,UAAU"}
@@ -1,5 +1,4 @@
1
- import { c as DecisionPlugin } from "../index-Cgg-w0hb.mjs";
2
- import "../index-D7VrRpTx.mjs";
1
+ import { o as DecisionPlugin } from "../index-CK88FBE5.mjs";
3
2
  declare const plugin: DecisionPlugin;
4
3
  export { plugin as default };
5
4
  //# sourceMappingURL=strict.d.mts.map
@@ -1,5 +1,4 @@
1
- import { i as strict } from "../define-presets-clyqLZxo.mjs";
2
- import { t as presetPlugin } from "../preset-plugin-AAwedMeS.mjs";
1
+ import { a as strict, t as presetPlugin } from "../preset-plugin-MKdvpXxa.mjs";
3
2
  // src/app/strict.ts
4
3
  const plugin = presetPlugin(strict);
5
4
  export { plugin as default };
@@ -1 +1 @@
1
- {"version":3,"file":"strict.mjs","names":[],"sources":["../../src/app/strict.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { strict } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(strict);\n\nexport default plugin;\n"],"mappings":";;;AAMA,MAAM,SAAyB,aAAa,MAAM"}
1
+ {"version":3,"file":"strict.mjs","names":[],"sources":["../../src/app/strict.ts"],"sourcesContent":["import type { DecisionPlugin } from \"@r_masseater/oxlint-plugin-decision\";\n\nimport { strict } from \"#/features/define-presets/index.ts\";\n\nimport { presetPlugin } from \"./preset-plugin.ts\";\n\nconst plugin: DecisionPlugin = presetPlugin(strict);\n\nexport default plugin;\n"],"mappings":";;AAMA,MAAM,SAAyB,aAAa,MAAM"}
@@ -0,0 +1,232 @@
1
+ import { L as AnswerSchema, _ as snippetRefOf, b as PREFIX, c as messageOf, h as parseVerdicts, n as mergeResponses } from "./wire-CKpt_MBX.mjs";
2
+ import { Array, Clock, Effect, FileSystem, Function, Layer, Option, Path, Record, Schedule, Schema, pipe } from "effect";
3
+ import { runAsWorker } from "synckit";
4
+ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
5
+ import { Digest } from "effect/crypto";
6
+ import { layerDigest } from "@effect/platform-node-shared/NodeCrypto";
7
+ import { layer } from "@effect/platform-node-shared/NodeFileSystem";
8
+ import { layer as layer$1 } from "@effect/platform-node-shared/NodePath";
9
+ import { OtlpSerialization, OtlpTracer } from "effect/observability";
10
+ // src/features/serve-decisions/model/system-one.ts
11
+ const FIRST_REDIRECT = 300;
12
+ const RETRY_INITIAL_MS = 10;
13
+ const RETRY_EXPONENT = 2;
14
+ const Decisions = Schema.Struct({
15
+ model: Schema.String,
16
+ answers: Schema.Record(Schema.String, AnswerSchema)
17
+ });
18
+ const Envelope = Schema.Struct({ result: Decisions });
19
+ const ErrorMessage = Schema.Struct({ message: Schema.String });
20
+ const ErrorBody = Schema.Union([Schema.Struct({ errors: Schema.NonEmptyArray(ErrorMessage) }), Schema.Struct({ detail: ErrorMessage })]);
21
+ const decodeErrorBody = Schema.decodeUnknownOption(ErrorBody);
22
+ const messageOfBody = (body) => Option.match(decodeErrorBody(body), {
23
+ onNone: () => "request failed",
24
+ onSome: (decoded) => {
25
+ if ("detail" in decoded) return decoded.detail.message;
26
+ return pipe(decoded.errors, Array.map(({ message }) => message), Array.join("; "));
27
+ }
28
+ });
29
+ const failureOf = (response) => response.json.pipe(Effect.option, Effect.flatMap((body) => Effect.fail(`http ${String(response.status)}: ${body.pipe(Option.getOrUndefined, messageOfBody)}`)));
30
+ const decodeEnvelope = HttpClientResponse.schemaBodyJson(Envelope);
31
+ const decodeDecisions = HttpClientResponse.schemaBodyJson(Decisions);
32
+ const invalid = ({ message }) => `invalid response: ${message}`;
33
+ const decisionsOf = (response, envelope) => {
34
+ if (envelope) return decodeEnvelope(response).pipe(Effect.mapBoth({
35
+ onSuccess: ({ result }) => result,
36
+ onFailure: invalid
37
+ }));
38
+ return decodeDecisions(response).pipe(Effect.mapError(invalid));
39
+ };
40
+ /** @internal */
41
+ const sendSystemOne = Effect.fn("sendSystemOne")(function* sendSystemOne(call, wire) {
42
+ const client = (yield* HttpClient.HttpClient).pipe(HttpClient.retryTransient({
43
+ retryOn: "response-only",
44
+ schedule: Schedule.exponential(RETRY_INITIAL_MS, RETRY_EXPONENT)
45
+ }));
46
+ const response = yield* HttpClientRequest.post(call.url).pipe(HttpClientRequest.bearerToken(call.token), HttpClientRequest.setHeaders(call.headers), HttpClientRequest.bodyJsonUnsafe({
47
+ model: call.model,
48
+ state: wire.state,
49
+ questions: wire.questions
50
+ }), client.execute, Effect.mapError(({ message }) => `network: ${message}`));
51
+ if (response.status >= FIRST_REDIRECT) return yield* failureOf(response);
52
+ const decisions = yield* decisionsOf(response, call.envelope);
53
+ return {
54
+ model: decisions.model,
55
+ answers: decisions.answers
56
+ };
57
+ });
58
+ // src/features/serve-decisions/model/cache.ts
59
+ const DATA_FIRST_ARITY = 2;
60
+ const CACHE_VERSION = 8;
61
+ /** @internal */
62
+ const CACHE_DIR = `node_modules/.cache/${PREFIX}`;
63
+ const encodeJson = (value) => Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(value).pipe(Effect.orDie);
64
+ const contextOf = (request, ref) => pipe(Option.fromUndefinedOr(request.state.contexts), Option.flatMap(Record.get(ref)));
65
+ const keyOf = (endpoint, request, id) => {
66
+ const ref = snippetRefOf(id);
67
+ return {
68
+ version: CACHE_VERSION,
69
+ endpoint,
70
+ model: request.model,
71
+ snippet: request.state.snippets[ref],
72
+ context: Option.getOrNull(contextOf(request, ref)),
73
+ question: request.questions[id]
74
+ };
75
+ };
76
+ const cacheFile = Effect.fn("cacheFile")(function* cacheFile(key) {
77
+ const digest = yield* Digest.Digest;
78
+ const path = yield* Path.Path;
79
+ const json = yield* encodeJson(key);
80
+ const hash = yield* digest.digestHex(Digest.sha256, new TextEncoder().encode(json));
81
+ return path.resolve(CACHE_DIR, `${hash}.json`);
82
+ });
83
+ const CachedAnswerSchema = Schema.Struct({
84
+ model: Schema.NonEmptyString,
85
+ answer: AnswerSchema
86
+ });
87
+ const decodeCached = Schema.decodeOption(Schema.fromJsonString(CachedAnswerSchema));
88
+ /** @internal */
89
+ const isComplete = Function.dual(DATA_FIRST_ARITY, (response, request) => Option.liftThrowable(() => parseVerdicts(response, request).complete)().pipe(Option.getOrElse(() => false)));
90
+ const keptFor = (refs) => (record) => pipe(record, Record.filter((_value, ref) => refs.includes(ref)));
91
+ /** @internal */
92
+ const missingRequest = Function.dual(DATA_FIRST_ARITY, (request, missing) => {
93
+ const refs = pipe(missing, Array.map(snippetRefOf));
94
+ const kept = keptFor(refs);
95
+ return {
96
+ ...request,
97
+ state: {
98
+ ...request.state,
99
+ snippets: kept(request.state.snippets),
100
+ ...pipe(Option.fromUndefinedOr(request.state.contexts), Option.match({
101
+ onNone: () => ({}),
102
+ onSome: (contexts) => ({ contexts: kept(contexts) })
103
+ }))
104
+ },
105
+ questions: pipe(request.questions, Record.filter((_question, id) => missing.includes(id)))
106
+ };
107
+ });
108
+ const validFor = (request, id) => ({ model, answer }) => isComplete({
109
+ model,
110
+ answers: { [id]: answer }
111
+ }, pipe(request, missingRequest([id])));
112
+ const readOne = Effect.fn("readOne")(function* readOne(endpoint, request, id) {
113
+ const fs = yield* FileSystem.FileSystem;
114
+ const file = yield* cacheFile(keyOf(endpoint, request, id));
115
+ const text = yield* fs.readFileString(file).pipe(Effect.option);
116
+ return {
117
+ id,
118
+ file,
119
+ cached: pipe(text, Option.flatMap(decodeCached), Option.filter(validFor(request, id)))
120
+ };
121
+ });
122
+ /** @internal */
123
+ const readCache = Effect.fn("readCache")(function* readCache(endpoint, request) {
124
+ return yield* Effect.forEach(Record.keys(request.questions), (id) => readOne(endpoint, request, id), { concurrency: "unbounded" });
125
+ });
126
+ /** @internal */
127
+ const cachedAnswers = (entries) => Record.fromEntries(pipe(entries, Array.flatMap(({ id, cached }) => pipe(cached, Option.map(({ answer }) => [id, answer]), Option.toArray))));
128
+ /** @internal */
129
+ const writeCache = Effect.fn("writeCache")(function* writeCache(file, cached) {
130
+ const fs = yield* FileSystem.FileSystem;
131
+ const path = yield* Path.Path;
132
+ const now = yield* Clock.currentTimeMillis;
133
+ const temp = `${file}.tmp-${String(now)}`;
134
+ const json = yield* encodeJson(cached);
135
+ yield* fs.makeDirectory(path.dirname(file), { recursive: true });
136
+ yield* fs.writeFileString(temp, json);
137
+ yield* fs.rename(temp, file);
138
+ });
139
+ // src/features/serve-decisions/model/services.ts
140
+ const tracing = OtlpTracer.layerFromConfig({ resource: { serviceName: "oxlint-plugin-decision" } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
141
+ /** @internal */
142
+ const workerServices = [
143
+ layer,
144
+ layer$1,
145
+ layerDigest,
146
+ FetchHttpClient.layer,
147
+ tracing
148
+ ];
149
+ // src/features/serve-decisions/model/serve-decisions.ts
150
+ const ask = Effect.fn("ask")(function* ask(transport, endpoint, { request, timeoutMs, env }) {
151
+ const responses = yield* Effect.forEach(transport.wires(request), (wire) => transport.send(endpoint, wire, { env }), { concurrency: "unbounded" }).pipe(Effect.timeoutOrElse({
152
+ duration: timeoutMs,
153
+ orElse: () => Effect.fail("timeout")
154
+ }));
155
+ return mergeResponses(responses);
156
+ });
157
+ const store = Effect.fn("store")(function* store(entries, response) {
158
+ yield* Effect.forEach(entries, ({ id, file }) => Option.match(Option.fromUndefinedOr(response.answers[id]), {
159
+ onNone: () => Effect.void,
160
+ onSome: (answer) => writeCache(file, {
161
+ model: response.model,
162
+ answer
163
+ }).pipe(Effect.ignore)
164
+ }), {
165
+ concurrency: "unbounded",
166
+ discard: true
167
+ });
168
+ });
169
+ const servedModel = (entries) => pipe(entries, Array.findFirst(({ cached }) => cached), Option.map(({ model }) => model));
170
+ const idsOf = (entries) => pipe(entries, Array.map(({ id }) => id));
171
+ const askMissing = Effect.fn("askMissing")(function* askMissing(transport, { endpoint, entries }, input) {
172
+ const missing = pipe(entries, Array.filter(({ cached }) => Option.isNone(cached)));
173
+ yield* Effect.annotateCurrentSpan({ askedQuestions: missing.length });
174
+ const request = pipe(input.request, missingRequest(idsOf(missing)));
175
+ const asked = yield* ask(transport, endpoint, {
176
+ ...input,
177
+ request
178
+ });
179
+ const response = {
180
+ model: asked.model,
181
+ answers: {
182
+ ...cachedAnswers(entries),
183
+ ...asked.answers
184
+ }
185
+ };
186
+ if (isComplete(response, input.request)) yield* store(missing, asked);
187
+ return response;
188
+ });
189
+ const decide = Effect.fn("decide")(function* decide(transport, input) {
190
+ yield* Effect.annotateCurrentSpan({ model: input.request.model });
191
+ const endpoint = yield* transport.endpoint(input.env);
192
+ const entries = yield* readCache(endpoint, input.request);
193
+ const hit = pipe(entries, Array.every(({ cached }) => Option.isSome(cached)));
194
+ yield* Effect.annotateCurrentSpan({ cached: hit });
195
+ if (hit) return {
196
+ response: {
197
+ model: Option.getOrElse(servedModel(entries), () => input.request.model),
198
+ answers: cachedAnswers(entries)
199
+ },
200
+ cached: true
201
+ };
202
+ return {
203
+ response: yield* askMissing(transport, {
204
+ endpoint,
205
+ entries
206
+ }, input),
207
+ cached: false
208
+ };
209
+ });
210
+ const reasonOf = (error) => {
211
+ if (typeof error === "string") return error;
212
+ return messageOf(error);
213
+ };
214
+ const decideOne = (transport, input) => decide(transport, input).pipe(Effect.match({
215
+ onSuccess: ({ response, cached }) => ({
216
+ ok: true,
217
+ response,
218
+ cached
219
+ }),
220
+ onFailure: (error) => ({
221
+ ok: false,
222
+ reason: reasonOf(error)
223
+ })
224
+ }));
225
+ const decideEach = (transport, inputs) => Effect.all(pipe(inputs, Array.map((input) => decideOne(transport, input))), { concurrency: "unbounded" }).pipe(Effect.provide(workerServices));
226
+ /** @internal */
227
+ const serveDecisions = (transport) => {
228
+ runAsWorker((inputs) => Effect.runPromise(decideEach(transport, inputs)));
229
+ };
230
+ export { sendSystemOne as n, serveDecisions as t };
231
+
232
+ //# sourceMappingURL=serve-decisions-D6M-l2uy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve-decisions-D6M-l2uy.mjs","names":["Arr","Rec","Fn","Arr","fileSystem","path","Arr"],"sources":["../src/features/serve-decisions/model/system-one.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 { 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(\n `http ${String(response.status)}: ${body.pipe(Option.getOrUndefined, messageOfBody)}`,\n ),\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 {\n Array as Arr,\n Clock,\n Effect,\n FileSystem,\n Function as Fn,\n Option,\n Path,\n Record as Rec,\n Schema,\n pipe,\n} from \"effect\";\nimport { Digest } from \"effect/crypto\";\n\nimport { AnswerSchema, PREFIX, parseVerdicts, snippetRefOf } from \"#/entities/decision/index.ts\";\nimport type { Answer, DecisionRequest, DecisionResponse } from \"#/entities/decision/index.ts\";\n\nconst DATA_FIRST_ARITY = 2;\n\nconst CACHE_VERSION = 8;\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\nconst contextOf = (request: DecisionRequest, ref: string): Option.Option<string> =>\n pipe(Option.fromUndefinedOr(request.state.contexts), Option.flatMap(Rec.get(ref)));\n\nconst keyOf = (endpoint: string, request: DecisionRequest, id: string): unknown => {\n const ref = snippetRefOf(id);\n return {\n version: CACHE_VERSION,\n endpoint,\n model: request.model,\n snippet: request.state.snippets[ref],\n context: Option.getOrNull(contextOf(request, ref)),\n question: request.questions[id],\n };\n};\n\nconst cacheFile = Effect.fn(\"cacheFile\")(function* cacheFile(key: unknown) {\n const digest = yield* Digest.Digest;\n const path = yield* Path.Path;\n const json = yield* encodeJson(key);\n const hash = yield* digest.digestHex(Digest.sha256, new TextEncoder().encode(json));\n return path.resolve(CACHE_DIR, `${hash}.json`);\n});\n\nconst CachedAnswerSchema = Schema.Struct({ model: Schema.NonEmptyString, answer: AnswerSchema });\n\n/** @internal */\nexport interface CachedAnswer {\n readonly model: string;\n readonly answer: Answer;\n}\n\nconst decodeCached = Schema.decodeOption(Schema.fromJsonString(CachedAnswerSchema));\n\n/** @internal */\nexport interface QuestionCache {\n readonly id: string;\n readonly file: string;\n readonly cached: Option.Option<CachedAnswer>;\n}\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\nconst keptFor =\n (refs: readonly string[]) =>\n <Value>(record: Readonly<Record<string, Value>>): Record<string, Value> =>\n pipe(\n record,\n Rec.filter((_value, ref) => refs.includes(ref)),\n );\n\n/** @internal */\nexport const missingRequest: {\n (missing: readonly string[]): (request: DecisionRequest) => DecisionRequest;\n (request: DecisionRequest, missing: readonly string[]): DecisionRequest;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (request: DecisionRequest, missing: readonly string[]): DecisionRequest => {\n const refs = pipe(missing, Arr.map(snippetRefOf));\n const kept = keptFor(refs);\n return {\n ...request,\n state: {\n ...request.state,\n snippets: kept(request.state.snippets),\n ...pipe(\n Option.fromUndefinedOr(request.state.contexts),\n Option.match({\n onNone: () => ({}),\n onSome: (contexts) => ({ contexts: kept(contexts) }),\n }),\n ),\n },\n questions: pipe(\n request.questions,\n Rec.filter((_question, id) => missing.includes(id)),\n ),\n };\n },\n);\n\nconst validFor =\n (request: DecisionRequest, id: string) =>\n ({ model, answer }: CachedAnswer): boolean =>\n isComplete({ model, answers: { [id]: answer } }, pipe(request, missingRequest([id])));\n\nconst readOne = Effect.fn(\"readOne\")(function* readOne(\n endpoint: string,\n request: DecisionRequest,\n id: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const file = yield* cacheFile(keyOf(endpoint, request, id));\n const text = yield* fs.readFileString(file).pipe(Effect.option);\n const cached: Option.Option<CachedAnswer> = pipe(\n text,\n Option.flatMap(decodeCached),\n Option.filter(validFor(request, id)),\n );\n return { id, file, cached } satisfies QuestionCache;\n});\n\n/** @internal */\nexport const readCache = Effect.fn(\"readCache\")(function* readCache(\n endpoint: string,\n request: DecisionRequest,\n) {\n return yield* Effect.forEach(\n Rec.keys(request.questions),\n (id) => readOne(endpoint, request, id),\n {\n concurrency: \"unbounded\",\n },\n );\n});\n\n/** @internal */\nexport const cachedAnswers = (\n entries: readonly QuestionCache[],\n): Readonly<Record<string, Answer>> =>\n Rec.fromEntries(\n pipe(\n entries,\n Arr.flatMap(({ id, cached }) =>\n pipe(\n cached,\n Option.map(({ answer }) => [id, answer] as const),\n Option.toArray,\n ),\n ),\n ),\n );\n\n/** @internal */\nexport const writeCache = Effect.fn(\"writeCache\")(function* writeCache(\n file: string,\n cached: CachedAnswer,\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(cached);\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 { cachedAnswers, isComplete, missingRequest, readCache, writeCache } from \"./cache.ts\";\nimport type { CacheServices, QuestionCache } 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 store = Effect.fn(\"store\")(function* store(\n entries: readonly QuestionCache[],\n response: DecisionResponse,\n) {\n yield* Effect.forEach(\n entries,\n ({ id, file }: QuestionCache) =>\n Option.match(Option.fromUndefinedOr(response.answers[id]), {\n onNone: () => Effect.void,\n onSome: (answer) => writeCache(file, { model: response.model, answer }).pipe(Effect.ignore),\n }),\n { concurrency: \"unbounded\", discard: true },\n );\n});\n\nconst servedModel = (entries: readonly QuestionCache[]): Option.Option<string> =>\n pipe(\n entries,\n Arr.findFirst(({ cached }) => cached),\n Option.map(({ model }) => model),\n );\n\nconst idsOf = (entries: readonly QuestionCache[]): readonly string[] =>\n pipe(\n entries,\n Arr.map(({ id }) => id),\n );\n\nconst askMissing = Effect.fn(\"askMissing\")(function* askMissing(\n transport: Transport,\n { endpoint, entries }: Readonly<{ endpoint: string; entries: readonly QuestionCache[] }>,\n input: DecideInput,\n) {\n const missing = pipe(\n entries,\n Arr.filter(({ cached }) => Option.isNone(cached)),\n );\n yield* Effect.annotateCurrentSpan({ askedQuestions: missing.length });\n const request = pipe(input.request, missingRequest(idsOf(missing)));\n const asked = yield* ask(transport, endpoint, { ...input, request });\n const response = { model: asked.model, answers: { ...cachedAnswers(entries), ...asked.answers } };\n if (isComplete(response, input.request)) {\n yield* store(missing, asked);\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 entries = yield* readCache(endpoint, input.request);\n const hit = pipe(\n entries,\n Arr.every(({ cached }) => Option.isSome(cached)),\n );\n yield* Effect.annotateCurrentSpan({ cached: hit });\n if (hit) {\n const model = Option.getOrElse(servedModel(entries), () => input.request.model);\n return { response: { model, answers: cachedAnswers(entries) }, cached: true };\n }\n return { response: yield* askMissing(transport, { endpoint, entries }, 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":";;;;;;;;;;AAOA,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AAEvB,MAAM,YAAY,OAAO,OAAO;CAC9B,OAAO,OAAO;CACd,SAAS,OAAO,OAAO,OAAO,QAAQ,YAAY;AACpD,CAAC;AAED,MAAM,WAAW,OAAO,OAAO,EAAE,QAAQ,UAAU,CAAC;AAEpD,MAAM,eAAe,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,CAAC;AAE7D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C,KAAK,OAAO,QAAQ,cAAc,CAAC;;AAGvC,MAAa,kBAAkB,cAA+B;CAC5D,aAAa,WACX,OAAO,WAAW,WAAW,WAAW,MAAM,CAAC,CACjD;AACF"}
@@ -0,0 +1,29 @@
1
+ import { a as envNameOf, t as fileRequestsFor } from "./wire-CKpt_MBX.mjs";
2
+ import { n as sendSystemOne, t as serveDecisions } from "./serve-decisions-D6M-l2uy.mjs";
3
+ import { Config, Effect, String } from "effect";
4
+ // src/features/serve-decisions/model/typesafe.ts
5
+ const DEFAULT_BASE_URL = "https://api.typesafe.ai";
6
+ const SYSTEM_ONE_PATH = "/v1/systemone";
7
+ const TRAILING_SLASHES = /\/+$/u;
8
+ /** @internal */
9
+ const typesafeEndpointOf = (env) => Config.String(envNameOf(env, "TYPESAFE_BASE_URL")).pipe(Config.withDefault(DEFAULT_BASE_URL), Config.map((url) => String.replace(TRAILING_SLASHES, "")(String.trim(url))));
10
+ /** @internal */
11
+ const sendTypesafe = Effect.fn("sendTypesafe")(function* sendTypesafe(endpoint, wire, { env }) {
12
+ const token = yield* Config.Redacted(envNameOf(env, "TYPESAFE_API_KEY"));
13
+ return yield* sendSystemOne({
14
+ url: `${endpoint}${SYSTEM_ONE_PATH}`,
15
+ model: wire.model,
16
+ token,
17
+ headers: {},
18
+ envelope: false
19
+ }, wire);
20
+ });
21
+ // src/app/typesafe-worker.ts
22
+ serveDecisions({
23
+ endpoint: typesafeEndpointOf,
24
+ wires: fileRequestsFor,
25
+ send: sendTypesafe
26
+ });
27
+ export {};
28
+
29
+ //# sourceMappingURL=typesafe-worker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typesafe-worker.mjs","names":["Str"],"sources":["../src/features/serve-decisions/model/typesafe.ts","../src/app/typesafe-worker.ts"],"sourcesContent":["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 { 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,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;;AAGzB,MAAa,sBAAsB,QACjC,OAAO,OAAO,UAAU,KAAK,mBAAmB,CAAC,CAAC,CAAC,KACjD,OAAO,YAAY,gBAAgB,GACnC,OAAO,KAAK,QAAQA,OAAI,QAAQ,kBAAkB,EAAE,CAAC,CAACA,OAAI,KAAK,GAAG,CAAC,CAAC,CACtE;;AAGF,MAAa,eAAe,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,aAC9D,UACA,MACA,EAAE,OACF;CACA,MAAM,QAAQ,OAAO,OAAO,SAAS,UAAU,KAAK,kBAAkB,CAAC;CACvE,OAAO,OAAO,cACZ;EACE,KAAK,GAAG,WAAW;EACnB,OAAO,KAAK;EACZ;EACA,SAAS,CAAC;EACV,UAAU;CACZ,GACA,IACF;AACF,CAAC;;AC5BD,eAAe;CACb,UAAU;CACV,OAAO;CACP,MAAM;AACR,CAAC"}