@r_masseater/masseater-utils 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effect2rs.d.mts +13 -7
- package/dist/effect2rs.mjs +14 -10
- package/dist/effect2rs.mjs.map +1 -1
- package/dist/plugin-kit.d.mts +103 -2
- package/dist/plugin-kit.mjs +310 -8
- package/dist/plugin-kit.mjs.map +1 -1
- package/package.json +1 -1
package/dist/effect2rs.d.mts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Option, Schema, SchemaRepresentation } from "effect";
|
|
2
|
+
declare const UnsupportedSchema_base: Schema.Class<UnsupportedSchema, Schema.TaggedStruct<"UnsupportedSchema", {
|
|
3
|
+
readonly path: Schema.String;
|
|
4
|
+
readonly reason: Schema.String;
|
|
5
|
+
}>, import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly brand: unique symbol;
|
|
7
|
+
}>;
|
|
8
|
+
export declare class UnsupportedSchema extends UnsupportedSchema_base {}
|
|
2
9
|
interface RustFile {
|
|
3
10
|
readonly path: string;
|
|
4
11
|
readonly source: string;
|
|
@@ -21,13 +28,12 @@ declare const StaleRust_base: Schema.Class<StaleRust, Schema.TaggedStruct<"Stale
|
|
|
21
28
|
readonly brand: unique symbol;
|
|
22
29
|
}>;
|
|
23
30
|
export declare class StaleRust extends StaleRust_base {}
|
|
24
|
-
declare const
|
|
25
|
-
readonly
|
|
26
|
-
readonly reason: Schema.String;
|
|
31
|
+
declare const RustFileFailed_base: Schema.Class<RustFileFailed, Schema.TaggedStruct<"RustFileFailed", {
|
|
32
|
+
readonly message: Schema.String;
|
|
27
33
|
}>, import("effect/Cause").YieldableError & {
|
|
28
34
|
readonly brand: unique symbol;
|
|
29
35
|
}>;
|
|
30
|
-
export declare class
|
|
36
|
+
export declare class RustFileFailed extends RustFileFailed_base {}
|
|
31
37
|
export interface Effect2rsInput {
|
|
32
38
|
readonly definitions: Readonly<Record<string, unknown>>;
|
|
33
39
|
readonly header: string;
|
|
@@ -44,9 +50,9 @@ export declare const checkRust: (check: RustCheck) => Effect.Effect<void, HandWr
|
|
|
44
50
|
export interface RustOutput extends Effect2rsInput {
|
|
45
51
|
readonly output: string;
|
|
46
52
|
}
|
|
47
|
-
|
|
53
|
+
export type SyncFailure = StaleRust | HandWrittenCopies | UnsupportedSchema | RustFileFailed;
|
|
48
54
|
export declare const syncRust: (outputs: readonly RustOutput[], options: Readonly<{
|
|
49
55
|
check: boolean;
|
|
50
|
-
}>) => Effect.Effect<void,
|
|
56
|
+
}>) => Effect.Effect<void, SyncFailure>;
|
|
51
57
|
export type { RustFile };
|
|
52
58
|
//# sourceMappingURL=effect2rs.d.mts.map
|
package/dist/effect2rs.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Array, Boolean, Effect, FileSystem, Match, Option, Path, Predicate, Record, Schema, SchemaAST, SchemaRepresentation, String, pipe } from "effect";
|
|
1
|
+
import { Array, Boolean, Effect, FileSystem, Layer, Match, Option, Path, Predicate, Record, Schema, SchemaAST, SchemaRepresentation, String, pipe } from "effect";
|
|
2
|
+
import { layer } from "@effect/platform-node/NodeServices";
|
|
2
3
|
// src/entities/rust-item/model/integer.ts
|
|
3
4
|
const IS_INT = "effect/schema/isInt";
|
|
4
5
|
const ZERO = 0;
|
|
@@ -154,8 +155,8 @@ const VARIANT_RULES = [
|
|
|
154
155
|
];
|
|
155
156
|
const variantRule = (variants) => pipe(VARIANT_RULES, Array.findFirst(([, apply]) => pipe(variants, Array.every(({ variant, value }) => apply(variant) === value))), Option.map(([rule]) => rule));
|
|
156
157
|
// src/entities/rust-item/model/types.ts
|
|
157
|
-
const taggedError$
|
|
158
|
-
var UnsupportedSchema = class extends taggedError$
|
|
158
|
+
const taggedError$3 = Schema.TaggedError;
|
|
159
|
+
var UnsupportedSchema = class extends taggedError$3()("UnsupportedSchema", {
|
|
159
160
|
path: Schema.String,
|
|
160
161
|
reason: Schema.String
|
|
161
162
|
}) {};
|
|
@@ -366,13 +367,13 @@ const copiesOf = (generated) => (files) => {
|
|
|
366
367
|
return pipe(files, Array.flatMap(copiesIn(names)));
|
|
367
368
|
};
|
|
368
369
|
// src/features/check-rust/model/hand-written-copies.ts
|
|
369
|
-
const taggedError$
|
|
370
|
+
const taggedError$2 = Schema.TaggedError;
|
|
370
371
|
const CopyLocation = Schema.Struct({
|
|
371
372
|
path: Schema.String,
|
|
372
373
|
line: Schema.Finite,
|
|
373
374
|
name: Schema.String
|
|
374
375
|
});
|
|
375
|
-
var HandWrittenCopies = class extends taggedError$
|
|
376
|
+
var HandWrittenCopies = class extends taggedError$2()("HandWrittenCopies", {
|
|
376
377
|
copies: Schema.Array(CopyLocation),
|
|
377
378
|
message: Schema.String
|
|
378
379
|
}) {};
|
|
@@ -384,8 +385,8 @@ const handWrittenCopies = (copies) => {
|
|
|
384
385
|
});
|
|
385
386
|
};
|
|
386
387
|
// src/features/check-rust/model/stale-rust.ts
|
|
387
|
-
const taggedError = Schema.TaggedError;
|
|
388
|
-
var StaleRust = class extends taggedError()("StaleRust", {
|
|
388
|
+
const taggedError$1 = Schema.TaggedError;
|
|
389
|
+
var StaleRust = class extends taggedError$1()("StaleRust", {
|
|
389
390
|
path: Schema.String,
|
|
390
391
|
message: Schema.String
|
|
391
392
|
}) {};
|
|
@@ -393,6 +394,9 @@ const staleRust = (path) => StaleRust.make({
|
|
|
393
394
|
path,
|
|
394
395
|
message: `${path} does not match the Effect Schema. Generate it again with effect2rs.`
|
|
395
396
|
});
|
|
397
|
+
// src/features/check-rust/model/rust-file-failed.ts
|
|
398
|
+
const taggedError = Schema.TaggedError;
|
|
399
|
+
var RustFileFailed = class extends taggedError()("RustFileFailed", { message: Schema.String }) {};
|
|
396
400
|
// src/shared/lib/text.ts
|
|
397
401
|
const CONTROL_LIMIT = 32;
|
|
398
402
|
const HEX = 16;
|
|
@@ -851,8 +855,7 @@ const checkRustOutput = Effect.fn("effect2rs.checkRustOutput")(function* checkRu
|
|
|
851
855
|
siblings
|
|
852
856
|
});
|
|
853
857
|
});
|
|
854
|
-
|
|
855
|
-
const syncRust = Effect.fn("effect2rs.syncRust")(function* syncRust(outputs, options) {
|
|
858
|
+
const syncOutputs = Effect.fn("effect2rs.syncOutputs")(function* syncOutputs(outputs, options) {
|
|
856
859
|
if (options.check) {
|
|
857
860
|
yield* Effect.forEach(outputs, checkRustOutput, {
|
|
858
861
|
concurrency: 1,
|
|
@@ -865,6 +868,7 @@ const syncRust = Effect.fn("effect2rs.syncRust")(function* syncRust(outputs, opt
|
|
|
865
868
|
discard: true
|
|
866
869
|
});
|
|
867
870
|
});
|
|
868
|
-
|
|
871
|
+
const syncRust = (outputs, options) => Layer.build(layer).pipe(Effect.flatMap((services) => Effect.provideContext(syncOutputs(outputs, options), services)), Effect.catchTag("PlatformError", ({ message }) => Effect.fail(RustFileFailed.make({ message }))), Effect.scoped);
|
|
872
|
+
export { HandWrittenCopies, RustFileFailed, StaleRust, UnsupportedSchema, checkRust, effect2rs, syncRust };
|
|
869
873
|
|
|
870
874
|
//# sourceMappingURL=effect2rs.mjs.map
|
package/dist/effect2rs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect2rs.mjs","names":["taggedError","SINGLE","tagged","Arr","taggedError","Arr","Str"],"sources":["../src/entities/rust-item/model/integer.ts","../src/entities/rust-item/model/names.ts","../src/entities/rust-item/model/types.ts","../src/entities/rust-item/model/lower.ts","../src/entities/rust-item/model/items.ts","../src/features/check-rust/model/copies.ts","../src/features/check-rust/model/hand-written-copies.ts","../src/features/check-rust/model/stale-rust.ts","../src/shared/lib/text.ts","../src/features/render-rust/model/render-enum.ts","../src/features/render-rust/model/rust-type.ts","../src/features/render-rust/model/render-fields.ts","../src/features/render-rust/model/render-items.ts","../src/features/render-rust/model/render.ts","../src/app/effect2rs.ts"],"sourcesContent":["import { Array, Match, Option, Predicate, Schema, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nconst IS_INT = \"effect/schema/isInt\";\nconst ZERO = 0;\nconst STEP = 1;\nconst U32_MAX = 4_294_967_295;\nconst I32_MIN = -2_147_483_648;\nconst I32_MAX = 2_147_483_647;\n\nconst BoundsPayload = Schema.Struct({\n minimum: Schema.optionalKey(Schema.Finite),\n maximum: Schema.optionalKey(Schema.Finite),\n exclusiveMinimum: Schema.optionalKey(Schema.Union([Schema.Finite, Schema.Boolean])),\n exclusiveMaximum: Schema.optionalKey(Schema.Union([Schema.Finite, Schema.Boolean])),\n});\n\ntype Payload = typeof BoundsPayload.Type;\n\nconst decodePayload = Schema.decodeUnknownOption(BoundsPayload);\n\ntype Bounds = Readonly<{ int: boolean; min: number; max: number }>;\n\nconst filters = (\n checks: readonly SchemaRepresentation.Check[],\n): readonly SchemaRepresentation.Filter[] =>\n pipe(\n checks,\n Array.flatMap((check) =>\n Match.value(check).pipe(\n Match.tagsExhaustive({\n Filter: (filter) => [filter],\n FilterGroup: (group) => filters(group.checks),\n }),\n ),\n ),\n );\n\nconst shiftWhen =\n (step: number) =>\n (flag: number | boolean | undefined): number =>\n Match.value(flag).pipe(\n Match.when(true, () => step),\n Match.orElse(() => ZERO),\n );\n\nconst numbers = (values: readonly (number | boolean | undefined)[]): readonly number[] =>\n pipe(values, Array.filter(Predicate.isNumber));\n\nconst lows =\n (step: number) =>\n (payload: Payload): readonly number[] => [\n ...pipe(\n numbers([payload.minimum]),\n Array.map((minimum) => minimum + shiftWhen(step)(payload.exclusiveMinimum)),\n ),\n ...pipe(\n numbers([payload.exclusiveMinimum]),\n Array.map((minimum) => minimum + step),\n ),\n ];\n\nconst highs =\n (step: number) =>\n (payload: Payload): readonly number[] => [\n ...pipe(\n numbers([payload.maximum]),\n Array.map((maximum) => maximum - shiftWhen(step)(payload.exclusiveMaximum)),\n ),\n ...pipe(\n numbers([payload.exclusiveMaximum]),\n Array.map((maximum) => maximum - step),\n ),\n ];\n\nconst payloadOf = (filter: SchemaRepresentation.Filter): Option.Option<Payload> =>\n pipe(\n Option.fromNullishOr(filter.representation),\n Option.flatMap(({ payload }) => decodePayload(payload)),\n );\n\nconst isIntFilter = (filter: SchemaRepresentation.Filter): boolean =>\n pipe(\n Option.fromNullishOr(filter.representation),\n Option.exists(({ id }) => id === IS_INT),\n );\n\nconst choose = (bounds: Bounds): string =>\n Match.value(bounds).pipe(\n Match.when(\n ({ int }) => !int,\n () => \"f64\",\n ),\n Match.when(\n ({ min, max }) => min >= ZERO && max <= U32_MAX,\n () => \"u32\",\n ),\n Match.when(\n ({ min }) => min >= ZERO,\n () => \"u64\",\n ),\n Match.when(\n ({ min, max }) => min >= I32_MIN && max <= I32_MAX,\n () => \"i32\",\n ),\n Match.orElse(() => \"i64\"),\n );\n\nexport const numberType = (checks: readonly SchemaRepresentation.Check[]): string => {\n const flat = filters(checks);\n const int = pipe(flat, Array.some(isIntFilter));\n const step = Match.value(int).pipe(\n Match.when(true, () => STEP),\n Match.orElse(() => ZERO),\n );\n const payloads = pipe(flat, Array.map(payloadOf), Array.getSomes);\n const minimums = pipe(payloads, Array.flatMap(lows(step)));\n const maximums = pipe(payloads, Array.flatMap(highs(step)));\n return choose({\n int,\n min: Math.max(Number.NEGATIVE_INFINITY, ...minimums),\n max: Math.min(Number.POSITIVE_INFINITY, ...maximums),\n });\n};\n","import { Array, Boolean, Option, String, pipe } from \"effect\";\n\nconst KEYWORDS = new Set([\n \"as\",\n \"async\",\n \"await\",\n \"box\",\n \"break\",\n \"const\",\n \"continue\",\n \"dyn\",\n \"else\",\n \"enum\",\n \"extern\",\n \"false\",\n \"fn\",\n \"for\",\n \"gen\",\n \"if\",\n \"impl\",\n \"in\",\n \"let\",\n \"loop\",\n \"match\",\n \"mod\",\n \"move\",\n \"mut\",\n \"pub\",\n \"ref\",\n \"return\",\n \"static\",\n \"struct\",\n \"trait\",\n \"true\",\n \"try\",\n \"type\",\n \"unsafe\",\n \"use\",\n \"where\",\n \"while\",\n \"yield\",\n]);\n\nconst LOWER_TO_UPPER = /(?<before>[a-z0-9])(?<after>[A-Z])/gu;\nconst ACRONYM_END = /(?<acronym>[A-Z]+)(?<next>[A-Z][a-z])/gu;\nconst SEPARATOR = /[^A-Za-z0-9]+/u;\nconst LEADING_DIGIT = /^[0-9]/u;\nconst SCREAMING = /^[A-Z][A-Z0-9_]*$/u;\nconst INNER_UPPER = /(?<!^)(?<upper>[A-Z])/gu;\nconst RAW_PREFIX = /^r#/u;\nconst TRAILING_UNDERSCORES = /_+$/u;\n\nconst words = (value: string): readonly string[] =>\n pipe(\n value,\n String.replaceAll(LOWER_TO_UPPER, \"$<before> $<after>\"),\n String.replaceAll(ACRONYM_END, \"$<acronym> $<next>\"),\n String.split(SEPARATOR),\n Array.filter(String.isNonEmpty),\n );\n\nconst withLeadingDigit =\n (prefix: string) =>\n (value: string): string =>\n Boolean.match(LEADING_DIGIT.test(value), {\n onTrue: () => `${prefix}${value}`,\n onFalse: () => value,\n });\n\nconst capitalized = (word: string): string => pipe(word, String.toLowerCase, String.capitalize);\n\nexport const snakeCase = (value: string): string =>\n pipe(words(value), Array.map(String.toLowerCase), Array.join(\"_\"), withLeadingDigit(\"field_\"));\n\nconst pascalCase = (value: string): string =>\n pipe(words(value), Array.map(capitalized), Array.join(\"\"), withLeadingDigit(\"V\"));\n\nexport const screamingSnakeCase = (value: string): string =>\n Boolean.match(SCREAMING.test(value), {\n onTrue: () => value,\n onFalse: () => pipe(value, snakeCase, String.toUpperCase),\n });\n\nexport const plainIdentifier = (identifier: string): string =>\n pipe(identifier, String.replace(RAW_PREFIX, \"\"));\n\nconst UNRAWABLE = new Set([\"self\", \"super\", \"crate\", \"Self\"]);\nconst FIRST_SUFFIX = 2;\nconst NEXT = 1;\n\nconst orFallback =\n (fallback: string) =>\n (value: string): string =>\n Boolean.match(String.isNonEmpty(value), { onTrue: () => value, onFalse: () => fallback });\n\nconst awayFromKeywords =\n (suffix: string) =>\n (value: string): string =>\n Boolean.match(UNRAWABLE.has(value), {\n onTrue: () => `${value}${suffix}`,\n onFalse: () => value,\n });\n\nexport const fieldIdentifier = (snake: string): string => {\n const safe = pipe(snake, orFallback(\"value\"), awayFromKeywords(\"_\"));\n return Boolean.match(KEYWORDS.has(safe), { onTrue: () => `r#${safe}`, onFalse: () => safe });\n};\n\nexport const variantIdentifier = (value: string): string =>\n pipe(pascalCase(value), orFallback(\"Value\"), awayFromKeywords(\"Value\"));\n\nconst firstFree =\n (taken: readonly string[]) =>\n (separator: string) =>\n (name: string) =>\n (suffix: number): string => {\n const candidate = Boolean.match(suffix === FIRST_SUFFIX - NEXT, {\n onTrue: () => name,\n onFalse: () =>\n `${pipe(name, String.replace(TRAILING_UNDERSCORES, \"\"))}${separator}${globalThis.String(suffix)}`,\n });\n const used = pipe(taken, Array.contains(plainIdentifier(candidate)));\n return Boolean.match(used, {\n onTrue: () => firstFree(taken)(separator)(name)(Math.max(suffix + NEXT, FIRST_SUFFIX)),\n onFalse: () => candidate,\n });\n };\n\nconst distinctFrom =\n (separator: string) =>\n (taken: readonly string[]) =>\n (names: readonly string[]): readonly string[] =>\n pipe(\n names,\n Array.match({\n onEmpty: (): readonly string[] => [],\n onNonEmpty: ([name, ...rest]) => {\n const chosen = firstFree(taken)(separator)(name)(FIRST_SUFFIX - NEXT);\n return [chosen, ...distinctFrom(separator)([...taken, plainIdentifier(chosen)])(rest)];\n },\n }),\n );\n\nexport const distinct = (separator: string): ((names: readonly string[]) => readonly string[]) =>\n distinctFrom(separator)([]);\n\nexport const serdeCamelField = (field: string): string =>\n pipe(field, String.split(\"_\"), Array.map(String.capitalize), Array.join(\"\"), String.uncapitalize);\n\nconst snakeVariant =\n (separator: string) =>\n (variant: string): string =>\n pipe(variant, String.replaceAll(INNER_UPPER, `${separator}$<upper>`), String.toLowerCase);\n\nconst VARIANT_RULES: readonly (readonly [string, (variant: string) => string])[] = [\n [\"lowercase\", String.toLowerCase],\n [\"kebab-case\", snakeVariant(\"-\")],\n [\"snake_case\", snakeVariant(\"_\")],\n [\"camelCase\", String.uncapitalize],\n [\n \"SCREAMING_SNAKE_CASE\",\n (variant): string => pipe(variant, snakeVariant(\"_\"), String.toUpperCase),\n ],\n [\"UPPERCASE\", String.toUpperCase],\n];\n\nexport type Renamed = Readonly<{ variant: string; value: string }>;\n\nexport const variantRule = (variants: readonly Renamed[]): Option.Option<string> =>\n pipe(\n VARIANT_RULES,\n Array.findFirst(([, apply]) =>\n pipe(\n variants,\n Array.every(({ variant, value }) => apply(variant) === value),\n ),\n ),\n Option.map(([rule]) => rule),\n );\n","import { Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class UnsupportedSchema extends taggedError<\n UnsupportedSchema,\n { readonly brand: unique symbol }\n>()(\"UnsupportedSchema\", { path: Schema.String, reason: Schema.String }) {}\n\nexport interface Prim {\n readonly _tag: \"Prim\";\n readonly name: string;\n}\n\nexport interface Json {\n readonly _tag: \"Json\";\n}\n\nexport interface Named {\n readonly _tag: \"Named\";\n readonly name: string;\n}\n\nexport interface Optional {\n readonly _tag: \"Optional\";\n readonly of: Ty;\n}\n\nexport interface List {\n readonly _tag: \"List\";\n readonly of: Ty;\n}\n\nexport interface Dictionary {\n readonly _tag: \"Dictionary\";\n readonly key: Ty;\n readonly value: Ty;\n}\n\nexport interface Tuple {\n readonly _tag: \"Tuple\";\n readonly items: readonly Ty[];\n}\n\nexport interface Boxed {\n readonly _tag: \"Boxed\";\n readonly of: Ty;\n}\n\nexport type Ty = Prim | Json | Named | Optional | List | Dictionary | Tuple | Boxed;\n\nexport interface Field {\n readonly rust: string;\n readonly key: string;\n readonly ty: Ty;\n readonly skipNone: boolean;\n readonly doc: Option.Option<string>;\n}\n\nexport interface Variant {\n readonly value: string;\n readonly doc: Option.Option<string>;\n readonly fields: readonly Field[];\n}\n\nexport interface Struct {\n readonly _tag: \"Struct\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly fields: readonly Field[];\n}\n\nexport interface Enumeration {\n readonly _tag: \"Enumeration\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly values: readonly string[];\n}\n\nexport interface Tagged {\n readonly _tag: \"Tagged\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly tag: string;\n readonly variants: readonly Variant[];\n}\n\nexport interface Alias {\n readonly _tag: \"Alias\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly ty: Ty;\n}\n\nexport type Item = Struct | Enumeration | Tagged | Alias;\n\nexport interface Constant {\n readonly name: string;\n readonly value: string | number | boolean;\n}\n\nexport const prim = (name: string): Ty => ({ _tag: \"Prim\", name });\n\nexport const json: Ty = { _tag: \"Json\" };\n\nexport const named = (name: string): Ty => ({ _tag: \"Named\", name });\n\nexport const optional = (of: Ty): Ty => ({ _tag: \"Optional\", of });\n\nexport const list = (of: Ty): Ty => ({ _tag: \"List\", of });\n\nexport const dictionary = ([key, value]: readonly [Ty, Ty]): Ty => ({\n _tag: \"Dictionary\",\n key,\n value,\n});\n\nexport const tuple = (items: readonly Ty[]): Ty => ({ _tag: \"Tuple\", items });\n\nexport const boxed = (of: Ty): Ty => ({ _tag: \"Boxed\", of });\n","import { Array, Effect, Match, Option, Predicate, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nimport { numberType } from \"#/entities/rust-item/model/integer.ts\";\nimport { fieldIdentifier, snakeCase } from \"#/entities/rust-item/model/names.ts\";\nimport {\n UnsupportedSchema,\n boxed,\n dictionary,\n json,\n list,\n named,\n optional,\n prim,\n tuple,\n} from \"#/entities/rust-item/model/types.ts\";\nimport type { Field, Ty } from \"#/entities/rust-item/model/types.ts\";\n\ntype Representation = SchemaRepresentation.Representation;\n\nexport type Lowered = Effect.Effect<Ty, UnsupportedSchema>;\n\nconst SINGLE = 1;\n\nconst refuse =\n (path: string) =>\n (reason: string): Lowered =>\n Effect.fail(UnsupportedSchema.make({ path, reason }));\n\nconst isNull = (representation: Representation): boolean =>\n Predicate.isTagged(representation, \"Null\");\n\nconst isUndefined = (representation: Representation): boolean =>\n Predicate.isTagged(representation, \"Undefined\") || Predicate.isTagged(representation, \"Void\");\n\nconst isAbsent = (representation: Representation): boolean =>\n isNull(representation) || isUndefined(representation);\n\nexport interface Parts {\n readonly members: readonly SchemaRepresentation.Representation[];\n readonly nullable: boolean;\n readonly undefinable: boolean;\n}\n\nexport const partsOf = (representation: SchemaRepresentation.Representation): Parts =>\n Match.value(representation).pipe(\n Match.tag(\"Union\", ({ types }) => ({\n members: pipe(types, Array.filter(Predicate.not(isAbsent))),\n nullable: pipe(types, Array.some(isNull)),\n undefinable: pipe(types, Array.some(isUndefined)),\n })),\n Match.orElse(() => ({ members: [representation], nullable: false, undefinable: false })),\n );\n\nconst wrapOptional = (ty: Ty): Ty =>\n Match.value(ty).pipe(\n Match.tag(\"Optional\", () => ty),\n Match.orElse(() => optional(ty)),\n );\n\nconst optionalWhen =\n (absent: boolean) =>\n (ty: Ty): Ty =>\n Match.value(absent).pipe(\n Match.when(true, () => wrapOptional(ty)),\n Match.orElse(() => ty),\n );\n\nconst literal =\n (path: string) =>\n (value: string | number | boolean | bigint): Lowered =>\n Match.value(value).pipe(\n Match.when(Predicate.isString, () => Effect.succeed(prim(\"String\"))),\n Match.when(Predicate.isBoolean, () => Effect.succeed(prim(\"bool\"))),\n Match.when(Number.isInteger, () => Effect.succeed(prim(\"i64\"))),\n Match.when(Predicate.isNumber, () => Effect.succeed(prim(\"f64\"))),\n Match.orElse(() => refuse(path)(\"bigint literals have no JSON form\")),\n );\n\nexport type Lower = (\n path: string,\n) => (representation: SchemaRepresentation.Representation) => Lowered;\n\nconst UNION_REASON =\n \"only an identified union of string literals, or of structs sharing a literal tag, becomes a Rust enum\";\n\nconst union =\n (path: string, lower: Lower) =>\n (representation: Representation): Lowered => {\n const { members, nullable, undefinable } = partsOf(representation);\n return pipe(\n Option.liftPredicate(members, (all) => all.length === SINGLE),\n Option.flatMap(Array.head),\n Option.match({\n onNone: () => refuse(path)(UNION_REASON),\n onSome: (only) =>\n pipe(lower(path)(only), Effect.map(optionalWhen(nullable || undefinable))),\n }),\n );\n };\n\nconst objects =\n (path: string, lower: Lower) =>\n (object: SchemaRepresentation.Objects): Lowered =>\n pipe(\n Array.head(object.indexSignatures),\n Option.filter(() => Array.isReadonlyArrayEmpty(object.propertySignatures)),\n Option.match({\n onNone: () => refuse(path)(\"a struct needs an identifier\"),\n onSome: ({ parameter, type }) =>\n pipe(\n Effect.all([lower(`${path}[key]`)(parameter), lower(`${path}[]`)(type)], {\n concurrency: 1,\n }),\n Effect.map(dictionary),\n ),\n }),\n );\n\nconst isList = ({ elements, rest }: SchemaRepresentation.Arrays): boolean =>\n Array.isReadonlyArrayEmpty(elements) && rest.length === SINGLE;\n\nconst isTuple = ({ elements, rest }: SchemaRepresentation.Arrays): boolean =>\n Array.isReadonlyArrayEmpty(rest) && Array.isReadonlyArrayNonEmpty(elements);\n\nconst arrays =\n (path: string, lower: Lower) =>\n (array: SchemaRepresentation.Arrays): Lowered =>\n Match.value(array).pipe(\n Match.when(isList, ({ rest }) =>\n pipe(\n Array.head(rest),\n Option.match({\n onNone: () => refuse(path)(\"an array needs an element type\"),\n onSome: (element) => pipe(lower(`${path}[]`)(element), Effect.map(list)),\n }),\n ),\n ),\n Match.when(isTuple, ({ elements }) =>\n pipe(\n elements,\n (items) =>\n Effect.forEach(items, ({ type }, index) => lower(`${path}[${index}]`)(type), {\n concurrency: 1,\n }),\n Effect.map(tuple),\n ),\n ),\n Match.orElse(() => refuse(path)(\"only arrays and fixed tuples are supported\")),\n );\n\nexport const lower: Lower = (path) => (representation) =>\n Match.value(representation).pipe(\n Match.tagsExhaustive({\n Reference: ({ $ref }) => Effect.succeed(named($ref)),\n String: () => Effect.succeed(prim(\"String\")),\n TemplateLiteral: () => Effect.succeed(prim(\"String\")),\n Boolean: () => Effect.succeed(prim(\"bool\")),\n Number: ({ checks }) => Effect.succeed(prim(numberType(checks))),\n Unknown: () => Effect.succeed(json),\n Any: () => Effect.succeed(json),\n ObjectKeyword: () => Effect.succeed(json),\n Literal: ({ literal: value }) => literal(path)(value),\n Suspend: ({ thunk }) => pipe(lower(path)(thunk), Effect.map(boxed)),\n Union: union(path, lower),\n Objects: objects(path, lower),\n Arrays: arrays(path, lower),\n Enum: () => refuse(path)(\"an enum needs an identifier\"),\n Declaration: () => refuse(path)(\"a declaration has no wire form\"),\n Null: () => refuse(path)(\"null alone has no Rust type\"),\n Undefined: () => refuse(path)(\"undefined alone has no Rust type\"),\n Void: () => refuse(path)(\"void has no Rust type\"),\n Never: () => refuse(path)(\"never has no Rust type\"),\n BigInt: () => refuse(path)(\"bigint has no JSON form\"),\n Symbol: () => refuse(path)(\"symbol has no JSON form\"),\n UniqueSymbol: () => refuse(path)(\"symbol has no JSON form\"),\n }),\n );\n\nexport const descriptionOf = (value: unknown): Option.Option<string> =>\n pipe(\n Option.liftPredicate(value, Predicate.hasProperty(\"annotations\")),\n Option.flatMapNullishOr(({ annotations }) => annotations),\n Option.filter(Predicate.hasProperty(\"description\")),\n Option.map(({ description }) => description),\n Option.filter(Predicate.isString),\n );\n\nconst fieldDescription = (\n signature: SchemaRepresentation.PropertySignature,\n): Option.Option<string> =>\n pipe(\n descriptionOf(signature),\n Option.orElse(() => descriptionOf(signature.type)),\n );\n\nconst keyedField =\n (path: string, signature: SchemaRepresentation.PropertySignature) =>\n (key: string): Effect.Effect<Field, UnsupportedSchema> => {\n const { nullable, undefinable } = partsOf(signature.type);\n const absent = signature.isOptional || undefinable;\n return pipe(\n lower(`${path}.${key}`)(signature.type),\n Effect.map((ty) => ({\n rust: fieldIdentifier(snakeCase(key)),\n key,\n ty: optionalWhen(absent)(ty),\n skipNone: absent && !nullable,\n doc: fieldDescription(signature),\n })),\n );\n };\n\nexport const field =\n (path: string) =>\n (signature: SchemaRepresentation.PropertySignature): Effect.Effect<Field, UnsupportedSchema> =>\n pipe(\n Option.liftPredicate(signature.name, Predicate.isString),\n Option.match({\n onNone: () =>\n Effect.fail(\n UnsupportedSchema.make({ path, reason: \"only string keys can become Rust fields\" }),\n ),\n onSome: keyedField(path, signature),\n }),\n );\n","import { Array, Effect, Match, Option, Predicate, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nimport { descriptionOf, field, lower, partsOf } from \"#/entities/rust-item/model/lower.ts\";\nimport { distinct } from \"#/entities/rust-item/model/names.ts\";\nimport type { Field, Item, UnsupportedSchema, Variant } from \"#/entities/rust-item/model/types.ts\";\n\ntype Representation = SchemaRepresentation.Representation;\ntype Objects = SchemaRepresentation.Objects;\ntype Built = Effect.Effect<Item, UnsupportedSchema>;\n\ntype Entry = readonly [string, SchemaRepresentation.Representation];\n\nconst MIN_VARIANTS = 2;\n\nconst resolve =\n (references: SchemaRepresentation.References) =>\n (representation: Representation): Representation =>\n Match.value(representation).pipe(\n Match.tag(\"Reference\", ({ $ref }) =>\n pipe(\n Option.fromNullishOr(references[$ref]),\n Option.getOrElse(() => representation),\n ),\n ),\n Match.orElse(() => representation),\n );\n\nconst stringLiteral = (representation: Representation): Option.Option<string> =>\n Match.value(representation).pipe(\n Match.tag(\"Literal\", ({ literal }) => Option.liftPredicate(literal, Predicate.isString)),\n Match.orElse(() => Option.none<string>()),\n );\n\nconst asObjects = (representation: Representation): Option.Option<Objects> =>\n Match.value(representation).pipe(\n Match.tag(\"Objects\", (objects) =>\n Option.liftPredicate(objects, ({ indexSignatures }) =>\n Array.isReadonlyArrayEmpty(indexSignatures),\n ),\n ),\n Match.orElse(() => Option.none<Objects>()),\n );\n\nconst allSome = <Value>(\n options: readonly Option.Option<Value>[],\n): Option.Option<readonly Value[]> => {\n const values = Array.getSomes(options);\n return Option.liftPredicate(values, (found) => found.length === options.length);\n};\n\nconst tagValue =\n (key: string) =>\n (objects: Objects): Option.Option<string> =>\n pipe(\n objects.propertySignatures,\n Array.findFirst(({ name }) => name === key),\n Option.flatMap(({ type }) => stringLiteral(type)),\n );\n\nconst distinctTags =\n (members: readonly Objects[]) =>\n (key: string): boolean => {\n const tags = pipe(members, Array.map(tagValue(key)));\n return pipe(\n allSome(tags),\n Option.exists((values) => new Set(values).size === values.length),\n );\n };\n\nconst discriminator = (members: readonly Objects[]): Option.Option<string> =>\n pipe(\n Array.head(members),\n Option.filter(() => members.length >= MIN_VARIANTS),\n Option.flatMap(({ propertySignatures }) =>\n pipe(\n propertySignatures,\n Array.map(({ name }) => name),\n Array.filter(Predicate.isString),\n Array.findFirst(distinctTags(members)),\n ),\n ),\n );\n\nconst withDistinctNames = (fields: readonly Field[]): readonly Field[] => {\n const names = pipe(\n fields,\n Array.map(({ rust }) => rust),\n distinct(\"_\"),\n );\n return pipe(\n fields,\n Array.zipWith(names, (entry, rust) => ({ ...entry, rust })),\n );\n};\n\nconst fieldsOf =\n (path: string, skip: Option.Option<string>) =>\n (objects: Objects): Effect.Effect<readonly Field[], UnsupportedSchema> =>\n pipe(\n objects.propertySignatures,\n Array.filter(({ name }) => !Option.contains(skip, name)),\n (items) => Effect.forEach(items, field(path), { concurrency: 1 }),\n Effect.map(withDistinctNames),\n );\n\nconst variantOf =\n (path: string, tag: string) =>\n (member: Objects): Effect.Effect<Variant, UnsupportedSchema> =>\n pipe(\n fieldsOf(path, Option.some(tag))(member),\n Effect.map((fields) => ({\n value: pipe(\n tagValue(tag)(member),\n Option.getOrElse(() => tag),\n ),\n doc: descriptionOf(member),\n fields,\n })),\n );\n\nconst alias = ([name, representation]: Entry): Built =>\n pipe(\n lower(name)(representation),\n Effect.map((ty) => ({ _tag: \"Alias\", name, doc: descriptionOf(representation), ty }) as const),\n );\n\nconst tagged =\n ([name, representation]: Entry) =>\n (members: readonly Objects[]): Option.Option<Built> =>\n pipe(\n discriminator(members),\n Option.map((tag) =>\n pipe(\n members,\n (items) => Effect.forEach(items, variantOf(name, tag), { concurrency: 1 }),\n Effect.map((variants): Item => ({\n _tag: \"Tagged\",\n name,\n doc: descriptionOf(representation),\n tag,\n variants,\n })),\n ),\n ),\n );\n\nconst enumeration =\n ([name, representation]: Entry) =>\n (values: readonly Option.Option<string>[]): Option.Option<Built> =>\n pipe(\n allSome(values),\n Option.filter(Array.isReadonlyArrayNonEmpty),\n Option.map((literals) =>\n Effect.succeed<Item>({\n _tag: \"Enumeration\",\n name,\n doc: descriptionOf(representation),\n values: literals,\n }),\n ),\n );\n\nconst unionItem =\n (references: SchemaRepresentation.References) =>\n (entry: Entry): Built => {\n const [, representation] = entry;\n const { members, nullable, undefinable } = partsOf(representation);\n const resolved = pipe(members, Array.map(resolve(references)));\n const objects = allSome(pipe(resolved, Array.map(asObjects)));\n const literals = pipe(members, Array.map(stringLiteral));\n const asTagged = (): Option.Option<Built> => pipe(objects, Option.flatMap(tagged(entry)));\n return pipe(\n Option.liftPredicate(members, () => !nullable && !undefinable),\n Option.flatMap(() => pipe(enumeration(entry)(literals), Option.orElse(asTagged))),\n Option.getOrElse(() => alias(entry)),\n );\n };\n\nconst enumItem =\n (entry: Entry) =>\n ({ enums }: SchemaRepresentation.Enum): Built => {\n const values = pipe(\n enums,\n Array.map(([, value]) => Option.liftPredicate(value, Predicate.isString)),\n );\n return pipe(\n enumeration(entry)(values),\n Option.getOrElse(() => alias(entry)),\n );\n };\n\nconst structItem = (entry: Entry): Built => {\n const [name, representation] = entry;\n return pipe(\n asObjects(representation),\n Option.match({\n onNone: () => alias(entry),\n onSome: (objects) =>\n pipe(\n fieldsOf(name, Option.none())(objects),\n Effect.map((fields): Item => ({\n _tag: \"Struct\",\n name,\n doc: descriptionOf(representation),\n fields,\n })),\n ),\n }),\n );\n};\n\nexport const itemOf =\n (references: SchemaRepresentation.References) =>\n (\n entry: readonly [string, SchemaRepresentation.Representation],\n ): Effect.Effect<Item, UnsupportedSchema> => {\n const [, representation] = entry;\n return Match.value(representation).pipe(\n Match.tag(\"Union\", () => unionItem(references)(entry)),\n Match.tag(\"Enum\", enumItem(entry)),\n Match.orElse(() => structItem(entry)),\n );\n };\n","import { Array as Arr, Option, String, pipe } from \"effect\";\n\nexport interface RustFile {\n readonly path: string;\n readonly source: string;\n}\n\nexport interface Copy {\n readonly path: string;\n readonly line: number;\n readonly name: string;\n}\n\ninterface Declared {\n readonly name: string;\n readonly index: number;\n}\n\nconst DECLARATION =\n /^[ \\t]*(?:pub(?:\\([^)]*\\))?[ \\t]+)?(?:struct|enum|type|const(?![ \\t]+(?:fn|unsafe|async|extern)\\b)|static)[ \\t]+(?<name>[A-Za-z_]\\w*)/gmu;\n\nconst START = 0;\n\nconst declaredIn = (source: string): readonly Declared[] =>\n pipe(\n Arr.fromIterable(String.matchAll(DECLARATION)(source)),\n Arr.flatMap((found) =>\n pipe(\n Option.fromNullishOr(found.groups),\n Option.flatMap(({ name }) => Option.fromNullishOr(name)),\n Option.map((name) => ({ name, index: found.index ?? START })),\n Option.toArray,\n ),\n ),\n );\n\nconst lineAt =\n (source: string) =>\n (index: number): number =>\n pipe(source, String.slice(START, index), String.split(\"\\n\"), Arr.length);\n\nconst copiesIn =\n (generated: readonly string[]) =>\n ({ path, source }: RustFile): readonly Copy[] =>\n pipe(\n declaredIn(source),\n Arr.filter(({ name }) => pipe(generated, Arr.contains(name))),\n Arr.map(({ name, index }) => ({ path, line: lineAt(source)(index), name })),\n );\n\nexport const copiesOf =\n (generated: string) =>\n (files: readonly RustFile[]): readonly Copy[] => {\n const names = pipe(\n declaredIn(generated),\n Arr.map(({ name }) => name),\n );\n return pipe(files, Arr.flatMap(copiesIn(names)));\n };\n","import { Array as Arr, Schema, pipe } from \"effect\";\n\nimport type { Copy } from \"#/features/check-rust/model/copies.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nconst CopyLocation = Schema.Struct({\n path: Schema.String,\n line: Schema.Finite,\n name: Schema.String,\n});\n\nexport class HandWrittenCopies extends taggedError<\n HandWrittenCopies,\n { readonly brand: unique symbol }\n>()(\"HandWrittenCopies\", { copies: Schema.Array(CopyLocation), message: Schema.String }) {}\n\nexport const handWrittenCopies = (copies: readonly Copy[]): HandWrittenCopies => {\n const places = pipe(\n copies,\n Arr.map(({ path, line, name }) => `${path}:${line} declares ${name}`),\n Arr.join(\"\\n\"),\n );\n return HandWrittenCopies.make({\n copies,\n message: `These Rust items are generated by effect2rs, so declare them only in the generated file and import them from there:\\n${places}`,\n });\n};\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class StaleRust extends taggedError<StaleRust, { readonly brand: unique symbol }>()(\n \"StaleRust\",\n { path: Schema.String, message: Schema.String },\n) {}\n\nexport const staleRust = (path: string): StaleRust =>\n StaleRust.make({\n path,\n message: `${path} does not match the Effect Schema. Generate it again with effect2rs.`,\n });\n","import { Array, Boolean, Match, Option, String, pipe } from \"effect\";\n\nconst CONTROL_LIMIT = 0x20;\nconst HEX = 16;\nconst FIRST = 0;\n\nconst { raw } = globalThis.String;\n\nexport const when =\n (condition: boolean) =>\n (lines: () => readonly string[]): readonly string[] =>\n Boolean.match(condition, { onTrue: lines, onFalse: () => [] });\n\nexport const docLines =\n (indent: string) =>\n (doc: Option.Option<string>): readonly string[] =>\n pipe(\n doc,\n Option.map((text) =>\n pipe(\n text,\n String.split(\"\\n\"),\n Array.map((line) => String.trimEnd(`${indent}/// ${line}`)),\n ),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst control = (char: string): Option.Option<number> =>\n pipe(\n char,\n String.codePointAt(FIRST),\n Option.filter((point) => point < CONTROL_LIMIT),\n );\n\nconst escapeChar = (char: string): string =>\n Match.value(char).pipe(\n Match.when(\"\\\\\", () => raw`\\\\`),\n Match.when('\"', () => raw`\\\"`),\n Match.when(\"\\n\", () => raw`\\n`),\n Match.when(\"\\r\", () => raw`\\r`),\n Match.when(\"\\t\", () => raw`\\t`),\n Match.orElse((value) =>\n pipe(\n control(value),\n Option.match({\n onNone: () => value,\n onSome: (point) => `${raw`\\u`}{${point.toString(HEX)}}`,\n }),\n ),\n ),\n );\n\nexport const escape = (value: string): string =>\n pipe(Array.fromIterable(value), Array.map(escapeChar), Array.join(\"\"));\n\nexport interface Attribute {\n readonly name: string;\n readonly parts: readonly string[];\n readonly indent: string;\n}\n\nexport const attribute = ({ name, parts, indent }: Attribute): readonly string[] =>\n when(Array.isReadonlyArrayNonEmpty(parts))(() => [\n `${indent}#[${name}(${pipe(parts, Array.join(\", \"))})]`,\n ]);\n","import { Array, Boolean, Option, pipe } from \"effect\";\n\nimport { distinct, variantIdentifier, variantRule } from \"#/entities/rust-item/index.ts\";\nimport type { Renamed, Enumeration } from \"#/entities/rust-item/index.ts\";\nimport { attribute, docLines, escape } from \"#/shared/lib/text.ts\";\n\nexport interface VariantNaming {\n readonly renameAll: readonly string[];\n readonly perVariant: (value: string) => readonly string[];\n}\n\nexport const variantsOf = (values: readonly string[]): readonly Renamed[] => {\n const names = pipe(values, Array.map(variantIdentifier), distinct(\"\"));\n return pipe(\n values,\n Array.zipWith(names, (value, variant) => ({ variant, value })),\n );\n};\n\nconst ruleFor = (variants: readonly Renamed[]): Option.Option<Option.Option<string>> => {\n const identity = pipe(\n variants,\n Array.every(({ variant, value }) => variant === value),\n );\n return Boolean.match(identity, {\n onTrue: () => Option.some(Option.none()),\n onFalse: () => pipe(variantRule(variants), Option.map(Option.some)),\n });\n};\n\nexport const variantNaming = (variants: readonly Renamed[]): VariantNaming => {\n const rule = ruleFor(variants);\n return {\n renameAll: pipe(\n rule,\n Option.flatten,\n Option.map((name) => `rename_all = \"${name}\"`),\n Option.toArray,\n ),\n perVariant: (value) =>\n Boolean.match(Option.isSome(rule), {\n onTrue: () => [],\n onFalse: () => [`rename = \"${escape(value)}\"`],\n }),\n };\n};\n\nconst ARM = \" \";\n\nconst asStr = (variants: readonly Renamed[]): readonly string[] => [\n \" #[must_use]\",\n \" pub const fn as_str(self) -> &'static str {\",\n \" match self {\",\n ...pipe(\n variants,\n Array.map(({ variant, value }) => `${ARM}Self::${variant} => \"${escape(value)}\",`),\n ),\n \" }\",\n \" }\",\n];\n\nconst parse = (variants: readonly Renamed[]): readonly string[] => [\n \" #[must_use]\",\n \" pub fn parse(value: &str) -> Option<Self> {\",\n \" match value {\",\n ...pipe(\n variants,\n Array.map(({ variant, value }) => `${ARM}\"${escape(value)}\" => Some(Self::${variant}),`),\n ),\n `${ARM}_ => None,`,\n \" }\",\n \" }\",\n];\n\nconst variantLines =\n (naming: VariantNaming) =>\n ({ variant, value }: Renamed): readonly string[] =>\n pipe(\n attribute({ name: \"serde\", parts: naming.perVariant(value), indent: \" \" }),\n Array.append(` ${variant},`),\n );\n\nexport const enumLines =\n (derive: string) =>\n ({ name, doc, values }: Enumeration): readonly string[] => {\n const variants = variantsOf(values);\n const naming = variantNaming(variants);\n return [\n ...docLines(\"\")(doc),\n derive,\n ...attribute({ name: \"serde\", parts: naming.renameAll, indent: \"\" }),\n `pub enum ${name} {`,\n ...pipe(variants, Array.flatMap(variantLines(naming))),\n \"}\",\n \"\",\n `impl ${name} {`,\n ...asStr(variants),\n \"\",\n ...parse(variants),\n \"}\",\n ];\n };\n","import type { Predicate } from \"effect\";\nimport { Array, Match, Option, pipe } from \"effect\";\n\nimport { prim } from \"#/entities/rust-item/index.ts\";\nimport type { Ty } from \"#/entities/rust-item/index.ts\";\n\nconst WIDE_INTEGERS = new Set([\"i64\", \"u64\"]);\nconst SPECTA_NUMBER = \"specta_typescript::Number\";\nconst SPECTA_UNKNOWN = \"specta_typescript::Unknown\";\nconst SINGLE = 1;\n\nconst tupleType = (items: readonly string[]): string =>\n Match.value(items.length).pipe(\n Match.when(SINGLE, () => `(${pipe(items, Array.join(\"\"))},)`),\n Match.orElse(() => `(${pipe(items, Array.join(\", \"))})`),\n );\n\nexport const rustType = (ty: Ty): string =>\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: ({ name }) => name,\n Json: () => \"serde_json::Value\",\n Named: ({ name }) => name,\n Optional: ({ of }) => `Option<${rustType(of)}>`,\n List: ({ of }) => `Vec<${rustType(of)}>`,\n Dictionary: ({ key, value }) => `BTreeMap<${rustType(key)}, ${rustType(value)}>`,\n Tuple: ({ items }) => tupleType(pipe(items, Array.map(rustType))),\n Boxed: ({ of }) => `Box<${rustType(of)}>`,\n }),\n );\n\nexport const spectaType =\n (aliasOf: (name: string) => Option.Option<Ty>) =>\n (ty: Ty): Ty =>\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: ({ name }) =>\n Match.value(WIDE_INTEGERS.has(name)).pipe(\n Match.when(true, () => prim(SPECTA_NUMBER)),\n Match.orElse(() => ty),\n ),\n Json: () => prim(SPECTA_UNKNOWN),\n Named: ({ name }) =>\n pipe(\n aliasOf(name),\n Option.flatMap((target) =>\n Option.liftPredicate(\n spectaType(aliasOf)(target),\n (override) => rustType(override) !== rustType(target),\n ),\n ),\n Option.getOrElse(() => ty),\n ),\n Optional: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n List: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n Boxed: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n Dictionary: (inner) => ({\n ...inner,\n key: spectaType(aliasOf)(inner.key),\n value: spectaType(aliasOf)(inner.value),\n }),\n Tuple: (inner) => ({ ...inner, items: pipe(inner.items, Array.map(spectaType(aliasOf))) }),\n }),\n );\n\nexport const someTy =\n (predicate: Predicate.Predicate<Ty>) =>\n (ty: Ty): boolean =>\n predicate(ty) ||\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: () => false,\n Json: () => false,\n Named: () => false,\n Optional: ({ of }) => someTy(predicate)(of),\n List: ({ of }) => someTy(predicate)(of),\n Boxed: ({ of }) => someTy(predicate)(of),\n Dictionary: ({ key, value }) => someTy(predicate)(key) || someTy(predicate)(value),\n Tuple: ({ items }) => pipe(items, Array.some(someTy(predicate))),\n }),\n );\n","import { Array, Boolean, pipe } from \"effect\";\n\nimport { plainIdentifier, serdeCamelField } from \"#/entities/rust-item/index.ts\";\nimport type { Field, Ty } from \"#/entities/rust-item/index.ts\";\nimport { rustType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { attribute, docLines, escape, when } from \"#/shared/lib/text.ts\";\n\nexport interface FieldStyle {\n readonly specta: (ty: Ty) => Ty;\n readonly visibility: string;\n readonly indent: string;\n readonly camel: boolean;\n}\n\nexport const camelCased = (fields: readonly Field[]): boolean =>\n pipe(\n fields,\n Array.some(({ rust, key }) => plainIdentifier(rust) !== key),\n );\n\nconst serdeParts =\n (camel: boolean) =>\n (field: Field): readonly string[] => {\n const plain = plainIdentifier(field.rust);\n const expected = Boolean.match(camel, {\n onTrue: () => serdeCamelField(plain),\n onFalse: () => plain,\n });\n return [\n ...when(expected !== field.key)(() => [`rename = \"${escape(field.key)}\"`]),\n ...when(field.skipNone)(() => ['skip_serializing_if = \"Option::is_none\"']),\n ];\n };\n\nconst spectaParts =\n (style: FieldStyle) =>\n (field: Field): readonly string[] => {\n const override = rustType(style.specta(field.ty));\n return when(override !== rustType(field.ty))(() => [`type = ${override}`]);\n };\n\nexport const fieldLines =\n (style: FieldStyle) =>\n (field: Field): readonly string[] => [\n ...docLines(style.indent)(field.doc),\n ...attribute({ name: \"serde\", parts: serdeParts(style.camel)(field), indent: style.indent }),\n ...attribute({ name: \"specta\", parts: spectaParts(style)(field), indent: style.indent }),\n `${style.indent}${style.visibility}${field.rust}: ${rustType(field.ty)},`,\n ];\n\nexport const renameAllCamel = (camel: boolean): readonly string[] =>\n when(camel)(() => ['rename_all = \"camelCase\"']);\n","import { Array, Match, String, pipe } from \"effect\";\n\nimport type { Item, Struct, Tagged, Ty, Variant } from \"#/entities/rust-item/index.ts\";\nimport { enumLines, variantNaming, variantsOf } from \"#/features/render-rust/model/render-enum.ts\";\nimport {\n camelCased,\n fieldLines,\n renameAllCamel,\n} from \"#/features/render-rust/model/render-fields.ts\";\nimport { rustType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { attribute, docLines, escape } from \"#/shared/lib/text.ts\";\n\nexport interface Style {\n readonly derive: (base: readonly string[]) => string;\n readonly specta: (ty: Ty) => Ty;\n readonly hasFloat: (name: string) => boolean;\n}\n\nconst COMPARABLE = [\"Debug\", \"Clone\", \"PartialEq\"];\nconst EQ = [...COMPARABLE, \"Eq\"];\nconst COPY = [\"Debug\", \"Clone\", \"Copy\", \"PartialEq\", \"Eq\", \"Hash\"];\nconst FIELD = \" \";\nconst VARIANT_FIELD = \" \";\n\nconst dataDerive =\n (style: Style) =>\n (name: string): string =>\n style.derive(\n Match.value(style.hasFloat(name)).pipe(\n Match.when(true, () => COMPARABLE),\n Match.orElse(() => EQ),\n ),\n );\n\nconst struct =\n (style: Style) =>\n (item: Struct): readonly string[] => {\n const camel = camelCased(item.fields);\n const lines = fieldLines({ specta: style.specta, visibility: \"pub \", indent: FIELD, camel });\n return [\n ...docLines(\"\")(item.doc),\n dataDerive(style)(item.name),\n ...attribute({ name: \"serde\", parts: renameAllCamel(camel), indent: \"\" }),\n `pub struct ${item.name} {`,\n ...pipe(item.fields, Array.flatMap(lines)),\n \"}\",\n ];\n };\n\ninterface Laid {\n readonly head: readonly string[];\n readonly name: string;\n readonly fields: readonly (readonly string[])[];\n}\n\nconst STRUCT_VARIANT_WIDTH = 35;\nconst MAX_WIDTH = 100;\nconst ONE_LINE_PUNCTUATION = \" { },\".length;\nconst SINGLE_LINE = 1;\nconst TRAILING_COMMA = /,$/u;\n\nconst laidOut =\n (style: Style, perVariant: (value: string) => readonly string[]) =>\n ([entry, name]: readonly [Variant, string]): Laid => {\n const lines = fieldLines({\n specta: style.specta,\n visibility: \"\",\n indent: VARIANT_FIELD,\n camel: camelCased(entry.fields),\n });\n return {\n head: [\n ...docLines(FIELD)(entry.doc),\n ...attribute({\n name: \"serde\",\n parts: [...perVariant(entry.value), ...renameAllCamel(camelCased(entry.fields))],\n indent: FIELD,\n }),\n ],\n name,\n fields: pipe(entry.fields, Array.map(lines)),\n };\n };\n\nconst oneLineText = ({ fields }: Laid): string =>\n pipe(\n fields,\n Array.flatMap((lines) => lines),\n Array.map((line) => pipe(line, String.trim, String.replace(TRAILING_COMMA, \"\"))),\n Array.join(\", \"),\n );\n\nconst isUnit = ({ fields }: Laid): boolean => Array.isReadonlyArrayEmpty(fields);\n\nconst fitsOneLine = (laid: Laid): boolean => {\n const text = oneLineText(laid);\n const plain = pipe(\n laid.fields,\n Array.every((lines) => lines.length === SINGLE_LINE),\n );\n const width = FIELD.length + laid.name.length + text.length + ONE_LINE_PUNCTUATION;\n return plain && text.length <= STRUCT_VARIANT_WIDTH && width <= MAX_WIDTH;\n};\n\nconst isMultiLine = (laid: Laid): boolean =>\n Array.isReadonlyArrayNonEmpty(laid.head) || (!isUnit(laid) && !fitsOneLine(laid));\n\nconst bodyOf =\n (vertical: boolean) =>\n (laid: Laid): readonly string[] =>\n Match.value({ unit: isUnit(laid), oneLine: !vertical && fitsOneLine(laid) }).pipe(\n Match.when({ unit: true }, () => [`${FIELD}${laid.name},`]),\n Match.when({ oneLine: true }, () => [`${FIELD}${laid.name} { ${oneLineText(laid)} },`]),\n Match.orElse(() => [\n `${FIELD}${laid.name} {`,\n ...pipe(\n laid.fields,\n Array.flatMap((lines) => lines),\n ),\n `${FIELD}},`,\n ]),\n );\n\nconst tagged =\n (style: Style) =>\n (item: Tagged): readonly string[] => {\n const variants = variantsOf(\n pipe(\n item.variants,\n Array.map(({ value }) => value),\n ),\n );\n const naming = variantNaming(variants);\n const laid = pipe(\n item.variants,\n Array.zipWith(variants, (entry, { variant: name }) => [entry, name] as const),\n Array.map(laidOut(style, naming.perVariant)),\n );\n const vertical = pipe(laid, Array.some(isMultiLine)) && !pipe(laid, Array.every(isMultiLine));\n return [\n ...docLines(\"\")(item.doc),\n dataDerive(style)(item.name),\n ...attribute({\n name: \"serde\",\n parts: [`tag = \"${escape(item.tag)}\"`, ...naming.renameAll],\n indent: \"\",\n }),\n `pub enum ${item.name} {`,\n ...pipe(\n laid,\n Array.flatMap((entry) => pipe(entry.head, Array.appendAll(bodyOf(vertical)(entry)))),\n ),\n \"}\",\n ];\n };\n\nexport const itemLines = (style: Style): ((item: Item) => readonly string[]) => {\n const enumeration = enumLines(style.derive(COPY));\n const structure = struct(style);\n const union = tagged(style);\n return (item) =>\n Match.value(item).pipe(\n Match.tagsExhaustive({\n Struct: structure,\n Tagged: union,\n Enumeration: enumeration,\n Alias: ({ name, doc, ty }) => [...docLines(\"\")(doc), `pub type ${name} = ${rustType(ty)};`],\n }),\n );\n};\n","import { Array, Match, Option, Predicate, Record, String, pipe } from \"effect\";\n\nimport { screamingSnakeCase } from \"#/entities/rust-item/index.ts\";\nimport type { Constant, Item, Ty } from \"#/entities/rust-item/index.ts\";\nimport { itemLines } from \"#/features/render-rust/model/render-items.ts\";\nimport { someTy, spectaType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { escape, when } from \"#/shared/lib/text.ts\";\n\nexport interface Rendering {\n readonly header: string;\n readonly derive: readonly string[];\n readonly items: readonly Item[];\n readonly imported: readonly Item[];\n readonly external: Readonly<Record<string, string>>;\n readonly constants: readonly Constant[];\n}\n\nconst SPECTA_TYPE = \"specta::Type\";\nconst PATH_SEPARATOR = \"::\";\n\nconst tysOf = (item: Item): readonly Ty[] =>\n Match.value(item).pipe(\n Match.tagsExhaustive({\n Struct: ({ fields }) =>\n pipe(\n fields,\n Array.map(({ ty }) => ty),\n ),\n Tagged: ({ variants }) =>\n pipe(\n variants,\n Array.flatMap(({ fields }) => fields),\n Array.map(({ ty }) => ty),\n ),\n Enumeration: () => [],\n Alias: ({ ty }) => [ty],\n }),\n );\n\nconst directFloat =\n (isFloat: (name: string) => boolean) =>\n (ty: Ty): boolean =>\n Match.value(ty).pipe(\n Match.tag(\"Prim\", ({ name }) => name === \"f64\"),\n Match.tag(\"Named\", ({ name }) => isFloat(name)),\n Match.orElse(() => false),\n );\n\nconst itemHasFloat = (isFloat: (name: string) => boolean): ((item: Item) => boolean) => {\n const floatTy = someTy(directFloat(isFloat));\n return (item) => pipe(tysOf(item), Array.some(floatTy));\n};\n\nconst floatsIn = (items: readonly Item[]): ((name: string) => boolean) => {\n const byName = new Map(\n pipe(\n items,\n Array.map((item) => [item.name, item] as const),\n ),\n );\n const memo = new Map<string, boolean>();\n const isFloat = (name: string): boolean =>\n pipe(\n Option.fromNullishOr(memo.get(name)),\n Option.getOrElse(() => {\n memo.set(name, false);\n const result = pipe(\n Option.fromNullishOr(byName.get(name)),\n Option.exists(itemHasFloat(isFloat)),\n );\n memo.set(name, result);\n return result;\n }),\n );\n return isFloat;\n};\n\nconst constantLine = ({ name, value }: Constant): string => {\n const rustName = screamingSnakeCase(name);\n return Match.value(value).pipe(\n Match.when(Predicate.isString, (text) => `pub const ${rustName}: &str = \"${escape(text)}\";`),\n Match.when(\n Predicate.isBoolean,\n (flag) => `pub const ${rustName}: bool = ${globalThis.String(flag)};`,\n ),\n Match.when(\n Number.isInteger,\n (count) => `pub const ${rustName}: i64 = ${globalThis.String(count)};`,\n ),\n Match.orElse((amount) => `pub const ${rustName}: f64 = ${globalThis.String(amount)};`),\n );\n};\n\nconst isMap = (ty: Ty): boolean => Predicate.isTagged(ty, \"Dictionary\");\n\nconst usesMap = (items: readonly Item[]): boolean =>\n pipe(items, Array.flatMap(tysOf), Array.some(someTy(isMap)));\n\nconst derivePaths = (derive: readonly string[]): readonly string[] =>\n pipe(derive, Array.filter(String.includes(PATH_SEPARATOR)));\n\nconst namesType =\n (name: string) =>\n (ty: Ty): boolean =>\n Predicate.isTagged(ty, \"Named\") && ty.name === name;\n\nconst usedBy =\n (tys: readonly Ty[]) =>\n ([name]: readonly [string, string]): boolean => {\n const named = someTy(namesType(name));\n return pipe(tys, Array.some(named));\n };\n\nconst usedExternals = ({ items, external }: Rendering): readonly string[] => {\n const used = usedBy(pipe(items, Array.flatMap(tysOf)));\n return pipe(\n Record.toEntries(external),\n Array.filter(used),\n Array.map(([, path]) => path),\n );\n};\n\nconst importLines = (rendering: Rendering): readonly string[] => {\n const { items, derive } = rendering;\n return pipe(\n when(Array.isReadonlyArrayNonEmpty(items))(() => [\n \"serde::{Deserialize, Serialize}\",\n ...derivePaths(derive),\n ...when(usesMap(items))(() => [\"std::collections::BTreeMap\"]),\n ...usedExternals(rendering),\n ]),\n Array.sortBy(String.Order),\n Array.map((path) => `use ${path};`),\n );\n};\n\nconst aliasesOf = (items: readonly Item[]): ReadonlyMap<string, Ty> =>\n new Map(\n pipe(\n items,\n Array.flatMap((item) =>\n Match.value(item).pipe(\n Match.tag(\"Alias\", ({ name, ty }) => [[name, ty] as const]),\n Match.orElse(() => []),\n ),\n ),\n ),\n );\n\nconst spectaOf = ({ derive, items, imported }: Rendering): ((ty: Ty) => Ty) => {\n const aliases = aliasesOf([...items, ...imported]);\n return Match.value(pipe(derive, Array.contains(SPECTA_TYPE))).pipe(\n Match.when(true, () => spectaType((name) => Option.fromNullishOr(aliases.get(name)))),\n Match.orElse(() => (ty: Ty) => ty),\n );\n};\n\nconst shortName = (path: string): string =>\n pipe(path, String.split(PATH_SEPARATOR), Array.lastNonEmpty);\n\nconst deriveLine =\n (extra: readonly string[]) =>\n (base: readonly string[]): string =>\n `#[derive(${pipe([...base, \"Serialize\", \"Deserialize\", ...extra], Array.join(\", \"))})]`;\n\nexport const render = (rendering: Rendering): string => {\n const extra = pipe(rendering.derive, Array.map(shortName));\n const lines = itemLines({\n derive: deriveLine(extra),\n specta: spectaOf(rendering),\n hasFloat: floatsIn([...rendering.items, ...rendering.imported]),\n });\n const sections = pipe(\n [\n [rendering.header],\n importLines(rendering),\n pipe(rendering.constants, Array.map(constantLine)),\n ...pipe(rendering.items, Array.map(lines)),\n ],\n Array.filter(Array.isReadonlyArrayNonEmpty),\n Array.map(Array.join(\"\\n\")),\n );\n return `${pipe(sections, Array.join(\"\\n\\n\"))}\\n`;\n};\n","import {\n Array,\n Effect,\n FileSystem,\n Option,\n Path,\n Predicate,\n Record,\n Schema,\n SchemaAST,\n SchemaRepresentation,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { itemOf, UnsupportedSchema } from \"#/entities/rust-item/index.ts\";\nimport type { Constant } from \"#/entities/rust-item/index.ts\";\nimport { copiesOf, handWrittenCopies, staleRust } from \"#/features/check-rust/index.ts\";\nimport type { RustFile } from \"#/features/check-rust/index.ts\";\nimport { render } from \"#/features/render-rust/index.ts\";\n\nexport { UnsupportedSchema } from \"#/entities/rust-item/index.ts\";\nexport { StaleRust } from \"#/features/check-rust/index.ts\";\nexport { HandWrittenCopies } from \"#/features/check-rust/index.ts\";\nexport type { RustFile } from \"#/features/check-rust/index.ts\";\n\nexport interface Effect2rsInput {\n readonly definitions: Readonly<Record<string, unknown>>;\n readonly header: string;\n readonly derive?: readonly string[];\n readonly external?: Readonly<Record<string, string>>;\n}\n\nconst isConstant = Predicate.or(\n Predicate.isString,\n Predicate.or(Predicate.isNumber, Predicate.isBoolean),\n);\n\nconst NAMED_BY_EXPORT: readonly Predicate.Predicate<SchemaAST.AST>[] = [\n SchemaAST.isObjects,\n SchemaAST.isUnion,\n SchemaAST.isEnum,\n SchemaAST.isDeclaration,\n SchemaAST.isArrays,\n SchemaAST.isSuspend,\n];\n\nconst namedByExport: Predicate.Predicate<SchemaAST.AST> = (ast) =>\n pipe(\n NAMED_BY_EXPORT,\n Array.some((guard) => guard(ast)),\n );\n\nconst isGenerated: Predicate.Predicate<SchemaAST.AST> = (ast) =>\n namedByExport(ast) || Predicate.isString(SchemaAST.resolveIdentifier(ast));\n\nconst constantOf = ([key, value]: readonly [string, unknown]): Effect.Effect<\n Constant,\n UnsupportedSchema\n> =>\n pipe(\n Option.liftPredicate(value, isConstant),\n Option.match({\n onNone: () =>\n Effect.fail(\n UnsupportedSchema.make({\n path: key,\n reason: \"exports must be schemas, strings, numbers, or booleans\",\n }),\n ),\n onSome: (constant) => Effect.succeed({ name: key, value: constant }),\n }),\n );\n\ninterface Document {\n readonly references: SchemaRepresentation.References;\n readonly chosen: ReadonlySet<string>;\n}\n\nconst schemasOf = (\n definitions: Readonly<Record<string, unknown>>,\n): readonly (readonly [string, Schema.Top])[] =>\n pipe(\n Record.toEntries(definitions),\n Array.filter((entry): entry is [string, Schema.Top] => {\n const [, value] = entry;\n return Schema.isSchema(value);\n }),\n );\n\nconst documentOf = (definitions: Readonly<Record<string, unknown>>): Document => {\n const schemas = schemasOf(definitions);\n const exported = new Map(\n pipe(\n schemas,\n Array.filter(([, schema]) => namedByExport(schema.ast)),\n Array.map(([key, schema]) => [schema.ast, key] as const),\n ),\n );\n const chosen = new Set<string>();\n const policy: SchemaRepresentation.ReferencePolicy = ({ ast, identifier }) =>\n pipe(\n Option.fromNullishOr(identifier),\n Option.orElse(() => Option.fromNullishOr(exported.get(ast))),\n Option.tap((name) => Option.some(chosen.add(name))),\n Option.getOrUndefined,\n );\n const references = pipe(\n schemas,\n Array.map(([, schema]) => schema.ast),\n Array.filter(isGenerated),\n Array.match({\n onEmpty: (): SchemaRepresentation.References => ({}),\n onNonEmpty: (asts) =>\n SchemaRepresentation.toRepresentations(asts, { referencePolicy: policy }).references,\n }),\n );\n return { references, chosen };\n};\n\nconst renamed = (name: string): UnsupportedSchema =>\n UnsupportedSchema.make({\n path: name,\n reason: \"another schema has the same name, or a recursive schema has no identifier\",\n });\n\nexport const effect2rs = Effect.fn(\"effect2rs\")(function* effect2rs(input: Effect2rsInput) {\n const constants = yield* pipe(\n Record.toEntries(input.definitions),\n Array.filter(([, value]) => !Schema.isSchema(value)),\n (items) => Effect.forEach(items, constantOf, { concurrency: 1 }),\n );\n const { references, chosen } = documentOf(input.definitions);\n const named = Record.toEntries(references);\n yield* pipe(\n named,\n Array.findFirst(([name]) => !chosen.has(name)),\n Option.match({\n onNone: () => Effect.void,\n onSome: ([name]) => Effect.fail(renamed(name)),\n }),\n );\n const items = yield* Effect.forEach(named, itemOf(references), { concurrency: 1 });\n const external = input.external ?? {};\n return render({\n header: input.header,\n derive: input.derive ?? [],\n items: pipe(\n items,\n Array.filter(({ name }) => !Record.has(external, name)),\n ),\n imported: pipe(\n items,\n Array.filter(({ name }) => Record.has(external, name)),\n ),\n external,\n constants,\n });\n});\n\nexport interface RustCheck extends Effect2rsInput {\n readonly path: string;\n readonly current: Option.Option<string>;\n readonly siblings: readonly RustFile[];\n}\n\nexport const checkRust = Effect.fn(\"effect2rs.checkRust\")(function* checkRust(check: RustCheck) {\n const source = yield* effect2rs(check);\n yield* pipe(\n check.current,\n Option.filter((current) => current === source),\n Option.match({\n onNone: () => Effect.fail(staleRust(check.path)),\n onSome: () => Effect.void,\n }),\n );\n return yield* pipe(\n copiesOf(source)(check.siblings),\n Array.match({\n onEmpty: () => Effect.void,\n onNonEmpty: (copies) => Effect.fail(handWrittenCopies(copies)),\n }),\n );\n});\n\nexport interface RustOutput extends Effect2rsInput {\n readonly output: string;\n}\n\nconst RUST_FILE = \".rs\";\n\nconst readRust = Effect.fn(\"effect2rs.readRust\")(function* readRust(file: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const source = yield* fileSystem.readFileString(file);\n return { path: file, source };\n});\n\nconst siblingsOf = Effect.fn(\"effect2rs.siblingsOf\")(function* siblingsOf(output: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = path.dirname(output);\n const entries = yield* fileSystem.readDirectory(directory, { recursive: true });\n const files = pipe(\n entries,\n Array.filter(Str.endsWith(RUST_FILE)),\n Array.map((entry) => path.join(directory, entry)),\n Array.filter((file) => path.resolve(file) !== path.resolve(output)),\n Array.sortBy(Str.Order),\n );\n return yield* Effect.forEach(files, readRust, { concurrency: 1 });\n});\n\nconst writeRust = Effect.fn(\"effect2rs.writeRust\")(function* writeRust(target: RustOutput) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const source = yield* effect2rs(target);\n yield* fileSystem.makeDirectory(path.dirname(target.output), { recursive: true });\n yield* fileSystem.writeFileString(target.output, source);\n});\n\nconst checkRustOutput = Effect.fn(\"effect2rs.checkRustOutput\")(function* checkRustOutput(\n target: RustOutput,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const current = yield* Effect.option(fileSystem.readFileString(target.output));\n const siblings = yield* siblingsOf(target.output);\n yield* checkRust({ ...target, path: target.output, current, siblings });\n});\n\n/** @stability experimental */\nexport const syncRust = Effect.fn(\"effect2rs.syncRust\")(function* syncRust(\n outputs: readonly RustOutput[],\n options: Readonly<{ check: boolean }>,\n) {\n if (options.check) {\n yield* Effect.forEach(outputs, checkRustOutput, { concurrency: 1, discard: true });\n return;\n }\n yield* Effect.forEach(outputs, writeRust, { concurrency: 1, discard: true });\n});\n"],"mappings":";;AAGA,MAAM,SAAS;AACf,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,UAAU;AAChB,MAAM,UAAU;AAEhB,MAAM,gBAAgB,OAAO,OAAO;CAClC,SAAS,OAAO,YAAY,OAAO,MAAM;CACzC,SAAS,OAAO,YAAY,OAAO,MAAM;CACzC,kBAAkB,OAAO,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;CAClF,kBAAkB,OAAO,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;AACpF,CAAC;AAID,MAAM,gBAAgB,OAAO,oBAAoB,aAAa;AAI9D,MAAM,WACJ,WAEA,KACE,QACA,MAAM,SAAS,UACb,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,eAAe;CACnB,SAAS,WAAW,CAAC,MAAM;CAC3B,cAAc,UAAU,QAAQ,MAAM,MAAM;AAC9C,CAAC,CACH,CACF,CACF;AAEF,MAAM,aACH,UACA,SACC,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK,YAAY,IAAI,GAC3B,MAAM,aAAa,IAAI,CACzB;AAEJ,MAAM,WAAW,WACf,KAAK,QAAQ,MAAM,OAAO,UAAU,QAAQ,CAAC;AAE/C,MAAM,QACH,UACA,YAAwC,CACvC,GAAG,KACD,QAAQ,CAAC,QAAQ,OAAO,CAAC,GACzB,MAAM,KAAK,YAAY,UAAU,UAAU,IAAI,CAAC,CAAC,QAAQ,gBAAgB,CAAC,CAC5E,GACA,GAAG,KACD,QAAQ,CAAC,QAAQ,gBAAgB,CAAC,G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D,OAAO,UAAU;EAAE,GAAG;EAAQ,MAAM,OAAO;EAAQ;EAAS;CAAS,CAAC;AACxE,CAAC;;AAGD,MAAa,WAAW,OAAO,GAAG,oBAAoB,CAAC,CAAC,UAAU,SAChE,SACA,SACA;CACA,IAAI,QAAQ,OAAO;EACjB,OAAO,OAAO,QAAQ,SAAS,iBAAiB;GAAE,aAAa;GAAG,SAAS;EAAK,CAAC;EACjF;CACF;CACA,OAAO,OAAO,QAAQ,SAAS,WAAW;EAAE,aAAa;EAAG,SAAS;CAAK,CAAC;AAC7E,CAAC"}
|
|
1
|
+
{"version":3,"file":"effect2rs.mjs","names":["taggedError","SINGLE","tagged","Arr","taggedError","Arr","taggedError","Str","nodeServices"],"sources":["../src/entities/rust-item/model/integer.ts","../src/entities/rust-item/model/names.ts","../src/entities/rust-item/model/types.ts","../src/entities/rust-item/model/lower.ts","../src/entities/rust-item/model/items.ts","../src/features/check-rust/model/copies.ts","../src/features/check-rust/model/hand-written-copies.ts","../src/features/check-rust/model/stale-rust.ts","../src/features/check-rust/model/rust-file-failed.ts","../src/shared/lib/text.ts","../src/features/render-rust/model/render-enum.ts","../src/features/render-rust/model/rust-type.ts","../src/features/render-rust/model/render-fields.ts","../src/features/render-rust/model/render-items.ts","../src/features/render-rust/model/render.ts","../src/app/effect2rs.ts"],"sourcesContent":["import { Array, Match, Option, Predicate, Schema, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nconst IS_INT = \"effect/schema/isInt\";\nconst ZERO = 0;\nconst STEP = 1;\nconst U32_MAX = 4_294_967_295;\nconst I32_MIN = -2_147_483_648;\nconst I32_MAX = 2_147_483_647;\n\nconst BoundsPayload = Schema.Struct({\n minimum: Schema.optionalKey(Schema.Finite),\n maximum: Schema.optionalKey(Schema.Finite),\n exclusiveMinimum: Schema.optionalKey(Schema.Union([Schema.Finite, Schema.Boolean])),\n exclusiveMaximum: Schema.optionalKey(Schema.Union([Schema.Finite, Schema.Boolean])),\n});\n\ntype Payload = typeof BoundsPayload.Type;\n\nconst decodePayload = Schema.decodeUnknownOption(BoundsPayload);\n\ntype Bounds = Readonly<{ int: boolean; min: number; max: number }>;\n\nconst filters = (\n checks: readonly SchemaRepresentation.Check[],\n): readonly SchemaRepresentation.Filter[] =>\n pipe(\n checks,\n Array.flatMap((check) =>\n Match.value(check).pipe(\n Match.tagsExhaustive({\n Filter: (filter) => [filter],\n FilterGroup: (group) => filters(group.checks),\n }),\n ),\n ),\n );\n\nconst shiftWhen =\n (step: number) =>\n (flag: number | boolean | undefined): number =>\n Match.value(flag).pipe(\n Match.when(true, () => step),\n Match.orElse(() => ZERO),\n );\n\nconst numbers = (values: readonly (number | boolean | undefined)[]): readonly number[] =>\n pipe(values, Array.filter(Predicate.isNumber));\n\nconst lows =\n (step: number) =>\n (payload: Payload): readonly number[] => [\n ...pipe(\n numbers([payload.minimum]),\n Array.map((minimum) => minimum + shiftWhen(step)(payload.exclusiveMinimum)),\n ),\n ...pipe(\n numbers([payload.exclusiveMinimum]),\n Array.map((minimum) => minimum + step),\n ),\n ];\n\nconst highs =\n (step: number) =>\n (payload: Payload): readonly number[] => [\n ...pipe(\n numbers([payload.maximum]),\n Array.map((maximum) => maximum - shiftWhen(step)(payload.exclusiveMaximum)),\n ),\n ...pipe(\n numbers([payload.exclusiveMaximum]),\n Array.map((maximum) => maximum - step),\n ),\n ];\n\nconst payloadOf = (filter: SchemaRepresentation.Filter): Option.Option<Payload> =>\n pipe(\n Option.fromNullishOr(filter.representation),\n Option.flatMap(({ payload }) => decodePayload(payload)),\n );\n\nconst isIntFilter = (filter: SchemaRepresentation.Filter): boolean =>\n pipe(\n Option.fromNullishOr(filter.representation),\n Option.exists(({ id }) => id === IS_INT),\n );\n\nconst choose = (bounds: Bounds): string =>\n Match.value(bounds).pipe(\n Match.when(\n ({ int }) => !int,\n () => \"f64\",\n ),\n Match.when(\n ({ min, max }) => min >= ZERO && max <= U32_MAX,\n () => \"u32\",\n ),\n Match.when(\n ({ min }) => min >= ZERO,\n () => \"u64\",\n ),\n Match.when(\n ({ min, max }) => min >= I32_MIN && max <= I32_MAX,\n () => \"i32\",\n ),\n Match.orElse(() => \"i64\"),\n );\n\nexport const numberType = (checks: readonly SchemaRepresentation.Check[]): string => {\n const flat = filters(checks);\n const int = pipe(flat, Array.some(isIntFilter));\n const step = Match.value(int).pipe(\n Match.when(true, () => STEP),\n Match.orElse(() => ZERO),\n );\n const payloads = pipe(flat, Array.map(payloadOf), Array.getSomes);\n const minimums = pipe(payloads, Array.flatMap(lows(step)));\n const maximums = pipe(payloads, Array.flatMap(highs(step)));\n return choose({\n int,\n min: Math.max(Number.NEGATIVE_INFINITY, ...minimums),\n max: Math.min(Number.POSITIVE_INFINITY, ...maximums),\n });\n};\n","import { Array, Boolean, Option, String, pipe } from \"effect\";\n\nconst KEYWORDS = new Set([\n \"as\",\n \"async\",\n \"await\",\n \"box\",\n \"break\",\n \"const\",\n \"continue\",\n \"dyn\",\n \"else\",\n \"enum\",\n \"extern\",\n \"false\",\n \"fn\",\n \"for\",\n \"gen\",\n \"if\",\n \"impl\",\n \"in\",\n \"let\",\n \"loop\",\n \"match\",\n \"mod\",\n \"move\",\n \"mut\",\n \"pub\",\n \"ref\",\n \"return\",\n \"static\",\n \"struct\",\n \"trait\",\n \"true\",\n \"try\",\n \"type\",\n \"unsafe\",\n \"use\",\n \"where\",\n \"while\",\n \"yield\",\n]);\n\nconst LOWER_TO_UPPER = /(?<before>[a-z0-9])(?<after>[A-Z])/gu;\nconst ACRONYM_END = /(?<acronym>[A-Z]+)(?<next>[A-Z][a-z])/gu;\nconst SEPARATOR = /[^A-Za-z0-9]+/u;\nconst LEADING_DIGIT = /^[0-9]/u;\nconst SCREAMING = /^[A-Z][A-Z0-9_]*$/u;\nconst INNER_UPPER = /(?<!^)(?<upper>[A-Z])/gu;\nconst RAW_PREFIX = /^r#/u;\nconst TRAILING_UNDERSCORES = /_+$/u;\n\nconst words = (value: string): readonly string[] =>\n pipe(\n value,\n String.replaceAll(LOWER_TO_UPPER, \"$<before> $<after>\"),\n String.replaceAll(ACRONYM_END, \"$<acronym> $<next>\"),\n String.split(SEPARATOR),\n Array.filter(String.isNonEmpty),\n );\n\nconst withLeadingDigit =\n (prefix: string) =>\n (value: string): string =>\n Boolean.match(LEADING_DIGIT.test(value), {\n onTrue: () => `${prefix}${value}`,\n onFalse: () => value,\n });\n\nconst capitalized = (word: string): string => pipe(word, String.toLowerCase, String.capitalize);\n\nexport const snakeCase = (value: string): string =>\n pipe(words(value), Array.map(String.toLowerCase), Array.join(\"_\"), withLeadingDigit(\"field_\"));\n\nconst pascalCase = (value: string): string =>\n pipe(words(value), Array.map(capitalized), Array.join(\"\"), withLeadingDigit(\"V\"));\n\nexport const screamingSnakeCase = (value: string): string =>\n Boolean.match(SCREAMING.test(value), {\n onTrue: () => value,\n onFalse: () => pipe(value, snakeCase, String.toUpperCase),\n });\n\nexport const plainIdentifier = (identifier: string): string =>\n pipe(identifier, String.replace(RAW_PREFIX, \"\"));\n\nconst UNRAWABLE = new Set([\"self\", \"super\", \"crate\", \"Self\"]);\nconst FIRST_SUFFIX = 2;\nconst NEXT = 1;\n\nconst orFallback =\n (fallback: string) =>\n (value: string): string =>\n Boolean.match(String.isNonEmpty(value), { onTrue: () => value, onFalse: () => fallback });\n\nconst awayFromKeywords =\n (suffix: string) =>\n (value: string): string =>\n Boolean.match(UNRAWABLE.has(value), {\n onTrue: () => `${value}${suffix}`,\n onFalse: () => value,\n });\n\nexport const fieldIdentifier = (snake: string): string => {\n const safe = pipe(snake, orFallback(\"value\"), awayFromKeywords(\"_\"));\n return Boolean.match(KEYWORDS.has(safe), { onTrue: () => `r#${safe}`, onFalse: () => safe });\n};\n\nexport const variantIdentifier = (value: string): string =>\n pipe(pascalCase(value), orFallback(\"Value\"), awayFromKeywords(\"Value\"));\n\nconst firstFree =\n (taken: readonly string[]) =>\n (separator: string) =>\n (name: string) =>\n (suffix: number): string => {\n const candidate = Boolean.match(suffix === FIRST_SUFFIX - NEXT, {\n onTrue: () => name,\n onFalse: () =>\n `${pipe(name, String.replace(TRAILING_UNDERSCORES, \"\"))}${separator}${globalThis.String(suffix)}`,\n });\n const used = pipe(taken, Array.contains(plainIdentifier(candidate)));\n return Boolean.match(used, {\n onTrue: () => firstFree(taken)(separator)(name)(Math.max(suffix + NEXT, FIRST_SUFFIX)),\n onFalse: () => candidate,\n });\n };\n\nconst distinctFrom =\n (separator: string) =>\n (taken: readonly string[]) =>\n (names: readonly string[]): readonly string[] =>\n pipe(\n names,\n Array.match({\n onEmpty: (): readonly string[] => [],\n onNonEmpty: ([name, ...rest]) => {\n const chosen = firstFree(taken)(separator)(name)(FIRST_SUFFIX - NEXT);\n return [chosen, ...distinctFrom(separator)([...taken, plainIdentifier(chosen)])(rest)];\n },\n }),\n );\n\nexport const distinct = (separator: string): ((names: readonly string[]) => readonly string[]) =>\n distinctFrom(separator)([]);\n\nexport const serdeCamelField = (field: string): string =>\n pipe(field, String.split(\"_\"), Array.map(String.capitalize), Array.join(\"\"), String.uncapitalize);\n\nconst snakeVariant =\n (separator: string) =>\n (variant: string): string =>\n pipe(variant, String.replaceAll(INNER_UPPER, `${separator}$<upper>`), String.toLowerCase);\n\nconst VARIANT_RULES: readonly (readonly [string, (variant: string) => string])[] = [\n [\"lowercase\", String.toLowerCase],\n [\"kebab-case\", snakeVariant(\"-\")],\n [\"snake_case\", snakeVariant(\"_\")],\n [\"camelCase\", String.uncapitalize],\n [\n \"SCREAMING_SNAKE_CASE\",\n (variant): string => pipe(variant, snakeVariant(\"_\"), String.toUpperCase),\n ],\n [\"UPPERCASE\", String.toUpperCase],\n];\n\nexport type Renamed = Readonly<{ variant: string; value: string }>;\n\nexport const variantRule = (variants: readonly Renamed[]): Option.Option<string> =>\n pipe(\n VARIANT_RULES,\n Array.findFirst(([, apply]) =>\n pipe(\n variants,\n Array.every(({ variant, value }) => apply(variant) === value),\n ),\n ),\n Option.map(([rule]) => rule),\n );\n","import { Schema } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class UnsupportedSchema extends taggedError<\n UnsupportedSchema,\n { readonly brand: unique symbol }\n>()(\"UnsupportedSchema\", { path: Schema.String, reason: Schema.String }) {}\n\nexport interface Prim {\n readonly _tag: \"Prim\";\n readonly name: string;\n}\n\nexport interface Json {\n readonly _tag: \"Json\";\n}\n\nexport interface Named {\n readonly _tag: \"Named\";\n readonly name: string;\n}\n\nexport interface Optional {\n readonly _tag: \"Optional\";\n readonly of: Ty;\n}\n\nexport interface List {\n readonly _tag: \"List\";\n readonly of: Ty;\n}\n\nexport interface Dictionary {\n readonly _tag: \"Dictionary\";\n readonly key: Ty;\n readonly value: Ty;\n}\n\nexport interface Tuple {\n readonly _tag: \"Tuple\";\n readonly items: readonly Ty[];\n}\n\nexport interface Boxed {\n readonly _tag: \"Boxed\";\n readonly of: Ty;\n}\n\nexport type Ty = Prim | Json | Named | Optional | List | Dictionary | Tuple | Boxed;\n\nexport interface Field {\n readonly rust: string;\n readonly key: string;\n readonly ty: Ty;\n readonly skipNone: boolean;\n readonly doc: Option.Option<string>;\n}\n\nexport interface Variant {\n readonly value: string;\n readonly doc: Option.Option<string>;\n readonly fields: readonly Field[];\n}\n\nexport interface Struct {\n readonly _tag: \"Struct\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly fields: readonly Field[];\n}\n\nexport interface Enumeration {\n readonly _tag: \"Enumeration\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly values: readonly string[];\n}\n\nexport interface Tagged {\n readonly _tag: \"Tagged\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly tag: string;\n readonly variants: readonly Variant[];\n}\n\nexport interface Alias {\n readonly _tag: \"Alias\";\n readonly name: string;\n readonly doc: Option.Option<string>;\n readonly ty: Ty;\n}\n\nexport type Item = Struct | Enumeration | Tagged | Alias;\n\nexport interface Constant {\n readonly name: string;\n readonly value: string | number | boolean;\n}\n\nexport const prim = (name: string): Ty => ({ _tag: \"Prim\", name });\n\nexport const json: Ty = { _tag: \"Json\" };\n\nexport const named = (name: string): Ty => ({ _tag: \"Named\", name });\n\nexport const optional = (of: Ty): Ty => ({ _tag: \"Optional\", of });\n\nexport const list = (of: Ty): Ty => ({ _tag: \"List\", of });\n\nexport const dictionary = ([key, value]: readonly [Ty, Ty]): Ty => ({\n _tag: \"Dictionary\",\n key,\n value,\n});\n\nexport const tuple = (items: readonly Ty[]): Ty => ({ _tag: \"Tuple\", items });\n\nexport const boxed = (of: Ty): Ty => ({ _tag: \"Boxed\", of });\n","import { Array, Effect, Match, Option, Predicate, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nimport { numberType } from \"#/entities/rust-item/model/integer.ts\";\nimport { fieldIdentifier, snakeCase } from \"#/entities/rust-item/model/names.ts\";\nimport {\n UnsupportedSchema,\n boxed,\n dictionary,\n json,\n list,\n named,\n optional,\n prim,\n tuple,\n} from \"#/entities/rust-item/model/types.ts\";\nimport type { Field, Ty } from \"#/entities/rust-item/model/types.ts\";\n\ntype Representation = SchemaRepresentation.Representation;\n\nexport type Lowered = Effect.Effect<Ty, UnsupportedSchema>;\n\nconst SINGLE = 1;\n\nconst refuse =\n (path: string) =>\n (reason: string): Lowered =>\n Effect.fail(UnsupportedSchema.make({ path, reason }));\n\nconst isNull = (representation: Representation): boolean =>\n Predicate.isTagged(representation, \"Null\");\n\nconst isUndefined = (representation: Representation): boolean =>\n Predicate.isTagged(representation, \"Undefined\") || Predicate.isTagged(representation, \"Void\");\n\nconst isAbsent = (representation: Representation): boolean =>\n isNull(representation) || isUndefined(representation);\n\nexport interface Parts {\n readonly members: readonly SchemaRepresentation.Representation[];\n readonly nullable: boolean;\n readonly undefinable: boolean;\n}\n\nexport const partsOf = (representation: SchemaRepresentation.Representation): Parts =>\n Match.value(representation).pipe(\n Match.tag(\"Union\", ({ types }) => ({\n members: pipe(types, Array.filter(Predicate.not(isAbsent))),\n nullable: pipe(types, Array.some(isNull)),\n undefinable: pipe(types, Array.some(isUndefined)),\n })),\n Match.orElse(() => ({ members: [representation], nullable: false, undefinable: false })),\n );\n\nconst wrapOptional = (ty: Ty): Ty =>\n Match.value(ty).pipe(\n Match.tag(\"Optional\", () => ty),\n Match.orElse(() => optional(ty)),\n );\n\nconst optionalWhen =\n (absent: boolean) =>\n (ty: Ty): Ty =>\n Match.value(absent).pipe(\n Match.when(true, () => wrapOptional(ty)),\n Match.orElse(() => ty),\n );\n\nconst literal =\n (path: string) =>\n (value: string | number | boolean | bigint): Lowered =>\n Match.value(value).pipe(\n Match.when(Predicate.isString, () => Effect.succeed(prim(\"String\"))),\n Match.when(Predicate.isBoolean, () => Effect.succeed(prim(\"bool\"))),\n Match.when(Number.isInteger, () => Effect.succeed(prim(\"i64\"))),\n Match.when(Predicate.isNumber, () => Effect.succeed(prim(\"f64\"))),\n Match.orElse(() => refuse(path)(\"bigint literals have no JSON form\")),\n );\n\nexport type Lower = (\n path: string,\n) => (representation: SchemaRepresentation.Representation) => Lowered;\n\nconst UNION_REASON =\n \"only an identified union of string literals, or of structs sharing a literal tag, becomes a Rust enum\";\n\nconst union =\n (path: string, lower: Lower) =>\n (representation: Representation): Lowered => {\n const { members, nullable, undefinable } = partsOf(representation);\n return pipe(\n Option.liftPredicate(members, (all) => all.length === SINGLE),\n Option.flatMap(Array.head),\n Option.match({\n onNone: () => refuse(path)(UNION_REASON),\n onSome: (only) =>\n pipe(lower(path)(only), Effect.map(optionalWhen(nullable || undefinable))),\n }),\n );\n };\n\nconst objects =\n (path: string, lower: Lower) =>\n (object: SchemaRepresentation.Objects): Lowered =>\n pipe(\n Array.head(object.indexSignatures),\n Option.filter(() => Array.isReadonlyArrayEmpty(object.propertySignatures)),\n Option.match({\n onNone: () => refuse(path)(\"a struct needs an identifier\"),\n onSome: ({ parameter, type }) =>\n pipe(\n Effect.all([lower(`${path}[key]`)(parameter), lower(`${path}[]`)(type)], {\n concurrency: 1,\n }),\n Effect.map(dictionary),\n ),\n }),\n );\n\nconst isList = ({ elements, rest }: SchemaRepresentation.Arrays): boolean =>\n Array.isReadonlyArrayEmpty(elements) && rest.length === SINGLE;\n\nconst isTuple = ({ elements, rest }: SchemaRepresentation.Arrays): boolean =>\n Array.isReadonlyArrayEmpty(rest) && Array.isReadonlyArrayNonEmpty(elements);\n\nconst arrays =\n (path: string, lower: Lower) =>\n (array: SchemaRepresentation.Arrays): Lowered =>\n Match.value(array).pipe(\n Match.when(isList, ({ rest }) =>\n pipe(\n Array.head(rest),\n Option.match({\n onNone: () => refuse(path)(\"an array needs an element type\"),\n onSome: (element) => pipe(lower(`${path}[]`)(element), Effect.map(list)),\n }),\n ),\n ),\n Match.when(isTuple, ({ elements }) =>\n pipe(\n elements,\n (items) =>\n Effect.forEach(items, ({ type }, index) => lower(`${path}[${index}]`)(type), {\n concurrency: 1,\n }),\n Effect.map(tuple),\n ),\n ),\n Match.orElse(() => refuse(path)(\"only arrays and fixed tuples are supported\")),\n );\n\nexport const lower: Lower = (path) => (representation) =>\n Match.value(representation).pipe(\n Match.tagsExhaustive({\n Reference: ({ $ref }) => Effect.succeed(named($ref)),\n String: () => Effect.succeed(prim(\"String\")),\n TemplateLiteral: () => Effect.succeed(prim(\"String\")),\n Boolean: () => Effect.succeed(prim(\"bool\")),\n Number: ({ checks }) => Effect.succeed(prim(numberType(checks))),\n Unknown: () => Effect.succeed(json),\n Any: () => Effect.succeed(json),\n ObjectKeyword: () => Effect.succeed(json),\n Literal: ({ literal: value }) => literal(path)(value),\n Suspend: ({ thunk }) => pipe(lower(path)(thunk), Effect.map(boxed)),\n Union: union(path, lower),\n Objects: objects(path, lower),\n Arrays: arrays(path, lower),\n Enum: () => refuse(path)(\"an enum needs an identifier\"),\n Declaration: () => refuse(path)(\"a declaration has no wire form\"),\n Null: () => refuse(path)(\"null alone has no Rust type\"),\n Undefined: () => refuse(path)(\"undefined alone has no Rust type\"),\n Void: () => refuse(path)(\"void has no Rust type\"),\n Never: () => refuse(path)(\"never has no Rust type\"),\n BigInt: () => refuse(path)(\"bigint has no JSON form\"),\n Symbol: () => refuse(path)(\"symbol has no JSON form\"),\n UniqueSymbol: () => refuse(path)(\"symbol has no JSON form\"),\n }),\n );\n\nexport const descriptionOf = (value: unknown): Option.Option<string> =>\n pipe(\n Option.liftPredicate(value, Predicate.hasProperty(\"annotations\")),\n Option.flatMapNullishOr(({ annotations }) => annotations),\n Option.filter(Predicate.hasProperty(\"description\")),\n Option.map(({ description }) => description),\n Option.filter(Predicate.isString),\n );\n\nconst fieldDescription = (\n signature: SchemaRepresentation.PropertySignature,\n): Option.Option<string> =>\n pipe(\n descriptionOf(signature),\n Option.orElse(() => descriptionOf(signature.type)),\n );\n\nconst keyedField =\n (path: string, signature: SchemaRepresentation.PropertySignature) =>\n (key: string): Effect.Effect<Field, UnsupportedSchema> => {\n const { nullable, undefinable } = partsOf(signature.type);\n const absent = signature.isOptional || undefinable;\n return pipe(\n lower(`${path}.${key}`)(signature.type),\n Effect.map((ty) => ({\n rust: fieldIdentifier(snakeCase(key)),\n key,\n ty: optionalWhen(absent)(ty),\n skipNone: absent && !nullable,\n doc: fieldDescription(signature),\n })),\n );\n };\n\nexport const field =\n (path: string) =>\n (signature: SchemaRepresentation.PropertySignature): Effect.Effect<Field, UnsupportedSchema> =>\n pipe(\n Option.liftPredicate(signature.name, Predicate.isString),\n Option.match({\n onNone: () =>\n Effect.fail(\n UnsupportedSchema.make({ path, reason: \"only string keys can become Rust fields\" }),\n ),\n onSome: keyedField(path, signature),\n }),\n );\n","import { Array, Effect, Match, Option, Predicate, pipe } from \"effect\";\nimport type { SchemaRepresentation } from \"effect\";\n\nimport { descriptionOf, field, lower, partsOf } from \"#/entities/rust-item/model/lower.ts\";\nimport { distinct } from \"#/entities/rust-item/model/names.ts\";\nimport type { Field, Item, UnsupportedSchema, Variant } from \"#/entities/rust-item/model/types.ts\";\n\ntype Representation = SchemaRepresentation.Representation;\ntype Objects = SchemaRepresentation.Objects;\ntype Built = Effect.Effect<Item, UnsupportedSchema>;\n\ntype Entry = readonly [string, SchemaRepresentation.Representation];\n\nconst MIN_VARIANTS = 2;\n\nconst resolve =\n (references: SchemaRepresentation.References) =>\n (representation: Representation): Representation =>\n Match.value(representation).pipe(\n Match.tag(\"Reference\", ({ $ref }) =>\n pipe(\n Option.fromNullishOr(references[$ref]),\n Option.getOrElse(() => representation),\n ),\n ),\n Match.orElse(() => representation),\n );\n\nconst stringLiteral = (representation: Representation): Option.Option<string> =>\n Match.value(representation).pipe(\n Match.tag(\"Literal\", ({ literal }) => Option.liftPredicate(literal, Predicate.isString)),\n Match.orElse(() => Option.none<string>()),\n );\n\nconst asObjects = (representation: Representation): Option.Option<Objects> =>\n Match.value(representation).pipe(\n Match.tag(\"Objects\", (objects) =>\n Option.liftPredicate(objects, ({ indexSignatures }) =>\n Array.isReadonlyArrayEmpty(indexSignatures),\n ),\n ),\n Match.orElse(() => Option.none<Objects>()),\n );\n\nconst allSome = <Value>(\n options: readonly Option.Option<Value>[],\n): Option.Option<readonly Value[]> => {\n const values = Array.getSomes(options);\n return Option.liftPredicate(values, (found) => found.length === options.length);\n};\n\nconst tagValue =\n (key: string) =>\n (objects: Objects): Option.Option<string> =>\n pipe(\n objects.propertySignatures,\n Array.findFirst(({ name }) => name === key),\n Option.flatMap(({ type }) => stringLiteral(type)),\n );\n\nconst distinctTags =\n (members: readonly Objects[]) =>\n (key: string): boolean => {\n const tags = pipe(members, Array.map(tagValue(key)));\n return pipe(\n allSome(tags),\n Option.exists((values) => new Set(values).size === values.length),\n );\n };\n\nconst discriminator = (members: readonly Objects[]): Option.Option<string> =>\n pipe(\n Array.head(members),\n Option.filter(() => members.length >= MIN_VARIANTS),\n Option.flatMap(({ propertySignatures }) =>\n pipe(\n propertySignatures,\n Array.map(({ name }) => name),\n Array.filter(Predicate.isString),\n Array.findFirst(distinctTags(members)),\n ),\n ),\n );\n\nconst withDistinctNames = (fields: readonly Field[]): readonly Field[] => {\n const names = pipe(\n fields,\n Array.map(({ rust }) => rust),\n distinct(\"_\"),\n );\n return pipe(\n fields,\n Array.zipWith(names, (entry, rust) => ({ ...entry, rust })),\n );\n};\n\nconst fieldsOf =\n (path: string, skip: Option.Option<string>) =>\n (objects: Objects): Effect.Effect<readonly Field[], UnsupportedSchema> =>\n pipe(\n objects.propertySignatures,\n Array.filter(({ name }) => !Option.contains(skip, name)),\n (items) => Effect.forEach(items, field(path), { concurrency: 1 }),\n Effect.map(withDistinctNames),\n );\n\nconst variantOf =\n (path: string, tag: string) =>\n (member: Objects): Effect.Effect<Variant, UnsupportedSchema> =>\n pipe(\n fieldsOf(path, Option.some(tag))(member),\n Effect.map((fields) => ({\n value: pipe(\n tagValue(tag)(member),\n Option.getOrElse(() => tag),\n ),\n doc: descriptionOf(member),\n fields,\n })),\n );\n\nconst alias = ([name, representation]: Entry): Built =>\n pipe(\n lower(name)(representation),\n Effect.map((ty) => ({ _tag: \"Alias\", name, doc: descriptionOf(representation), ty }) as const),\n );\n\nconst tagged =\n ([name, representation]: Entry) =>\n (members: readonly Objects[]): Option.Option<Built> =>\n pipe(\n discriminator(members),\n Option.map((tag) =>\n pipe(\n members,\n (items) => Effect.forEach(items, variantOf(name, tag), { concurrency: 1 }),\n Effect.map((variants): Item => ({\n _tag: \"Tagged\",\n name,\n doc: descriptionOf(representation),\n tag,\n variants,\n })),\n ),\n ),\n );\n\nconst enumeration =\n ([name, representation]: Entry) =>\n (values: readonly Option.Option<string>[]): Option.Option<Built> =>\n pipe(\n allSome(values),\n Option.filter(Array.isReadonlyArrayNonEmpty),\n Option.map((literals) =>\n Effect.succeed<Item>({\n _tag: \"Enumeration\",\n name,\n doc: descriptionOf(representation),\n values: literals,\n }),\n ),\n );\n\nconst unionItem =\n (references: SchemaRepresentation.References) =>\n (entry: Entry): Built => {\n const [, representation] = entry;\n const { members, nullable, undefinable } = partsOf(representation);\n const resolved = pipe(members, Array.map(resolve(references)));\n const objects = allSome(pipe(resolved, Array.map(asObjects)));\n const literals = pipe(members, Array.map(stringLiteral));\n const asTagged = (): Option.Option<Built> => pipe(objects, Option.flatMap(tagged(entry)));\n return pipe(\n Option.liftPredicate(members, () => !nullable && !undefinable),\n Option.flatMap(() => pipe(enumeration(entry)(literals), Option.orElse(asTagged))),\n Option.getOrElse(() => alias(entry)),\n );\n };\n\nconst enumItem =\n (entry: Entry) =>\n ({ enums }: SchemaRepresentation.Enum): Built => {\n const values = pipe(\n enums,\n Array.map(([, value]) => Option.liftPredicate(value, Predicate.isString)),\n );\n return pipe(\n enumeration(entry)(values),\n Option.getOrElse(() => alias(entry)),\n );\n };\n\nconst structItem = (entry: Entry): Built => {\n const [name, representation] = entry;\n return pipe(\n asObjects(representation),\n Option.match({\n onNone: () => alias(entry),\n onSome: (objects) =>\n pipe(\n fieldsOf(name, Option.none())(objects),\n Effect.map((fields): Item => ({\n _tag: \"Struct\",\n name,\n doc: descriptionOf(representation),\n fields,\n })),\n ),\n }),\n );\n};\n\nexport const itemOf =\n (references: SchemaRepresentation.References) =>\n (\n entry: readonly [string, SchemaRepresentation.Representation],\n ): Effect.Effect<Item, UnsupportedSchema> => {\n const [, representation] = entry;\n return Match.value(representation).pipe(\n Match.tag(\"Union\", () => unionItem(references)(entry)),\n Match.tag(\"Enum\", enumItem(entry)),\n Match.orElse(() => structItem(entry)),\n );\n };\n","import { Array as Arr, Option, String, pipe } from \"effect\";\n\nexport interface RustFile {\n readonly path: string;\n readonly source: string;\n}\n\nexport interface Copy {\n readonly path: string;\n readonly line: number;\n readonly name: string;\n}\n\ninterface Declared {\n readonly name: string;\n readonly index: number;\n}\n\nconst DECLARATION =\n /^[ \\t]*(?:pub(?:\\([^)]*\\))?[ \\t]+)?(?:struct|enum|type|const(?![ \\t]+(?:fn|unsafe|async|extern)\\b)|static)[ \\t]+(?<name>[A-Za-z_]\\w*)/gmu;\n\nconst START = 0;\n\nconst declaredIn = (source: string): readonly Declared[] =>\n pipe(\n Arr.fromIterable(String.matchAll(DECLARATION)(source)),\n Arr.flatMap((found) =>\n pipe(\n Option.fromNullishOr(found.groups),\n Option.flatMap(({ name }) => Option.fromNullishOr(name)),\n Option.map((name) => ({ name, index: found.index ?? START })),\n Option.toArray,\n ),\n ),\n );\n\nconst lineAt =\n (source: string) =>\n (index: number): number =>\n pipe(source, String.slice(START, index), String.split(\"\\n\"), Arr.length);\n\nconst copiesIn =\n (generated: readonly string[]) =>\n ({ path, source }: RustFile): readonly Copy[] =>\n pipe(\n declaredIn(source),\n Arr.filter(({ name }) => pipe(generated, Arr.contains(name))),\n Arr.map(({ name, index }) => ({ path, line: lineAt(source)(index), name })),\n );\n\nexport const copiesOf =\n (generated: string) =>\n (files: readonly RustFile[]): readonly Copy[] => {\n const names = pipe(\n declaredIn(generated),\n Arr.map(({ name }) => name),\n );\n return pipe(files, Arr.flatMap(copiesIn(names)));\n };\n","import { Array as Arr, Schema, pipe } from \"effect\";\n\nimport type { Copy } from \"#/features/check-rust/model/copies.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nconst CopyLocation = Schema.Struct({\n path: Schema.String,\n line: Schema.Finite,\n name: Schema.String,\n});\n\nexport class HandWrittenCopies extends taggedError<\n HandWrittenCopies,\n { readonly brand: unique symbol }\n>()(\"HandWrittenCopies\", { copies: Schema.Array(CopyLocation), message: Schema.String }) {}\n\nexport const handWrittenCopies = (copies: readonly Copy[]): HandWrittenCopies => {\n const places = pipe(\n copies,\n Arr.map(({ path, line, name }) => `${path}:${line} declares ${name}`),\n Arr.join(\"\\n\"),\n );\n return HandWrittenCopies.make({\n copies,\n message: `These Rust items are generated by effect2rs, so declare them only in the generated file and import them from there:\\n${places}`,\n });\n};\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class StaleRust extends taggedError<StaleRust, { readonly brand: unique symbol }>()(\n \"StaleRust\",\n { path: Schema.String, message: Schema.String },\n) {}\n\nexport const staleRust = (path: string): StaleRust =>\n StaleRust.make({\n path,\n message: `${path} does not match the Effect Schema. Generate it again with effect2rs.`,\n });\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class RustFileFailed extends taggedError<\n RustFileFailed,\n { readonly brand: unique symbol }\n>()(\"RustFileFailed\", { message: Schema.String }) {}\n","import { Array, Boolean, Match, Option, String, pipe } from \"effect\";\n\nconst CONTROL_LIMIT = 0x20;\nconst HEX = 16;\nconst FIRST = 0;\n\nconst { raw } = globalThis.String;\n\nexport const when =\n (condition: boolean) =>\n (lines: () => readonly string[]): readonly string[] =>\n Boolean.match(condition, { onTrue: lines, onFalse: () => [] });\n\nexport const docLines =\n (indent: string) =>\n (doc: Option.Option<string>): readonly string[] =>\n pipe(\n doc,\n Option.map((text) =>\n pipe(\n text,\n String.split(\"\\n\"),\n Array.map((line) => String.trimEnd(`${indent}/// ${line}`)),\n ),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst control = (char: string): Option.Option<number> =>\n pipe(\n char,\n String.codePointAt(FIRST),\n Option.filter((point) => point < CONTROL_LIMIT),\n );\n\nconst escapeChar = (char: string): string =>\n Match.value(char).pipe(\n Match.when(\"\\\\\", () => raw`\\\\`),\n Match.when('\"', () => raw`\\\"`),\n Match.when(\"\\n\", () => raw`\\n`),\n Match.when(\"\\r\", () => raw`\\r`),\n Match.when(\"\\t\", () => raw`\\t`),\n Match.orElse((value) =>\n pipe(\n control(value),\n Option.match({\n onNone: () => value,\n onSome: (point) => `${raw`\\u`}{${point.toString(HEX)}}`,\n }),\n ),\n ),\n );\n\nexport const escape = (value: string): string =>\n pipe(Array.fromIterable(value), Array.map(escapeChar), Array.join(\"\"));\n\nexport interface Attribute {\n readonly name: string;\n readonly parts: readonly string[];\n readonly indent: string;\n}\n\nexport const attribute = ({ name, parts, indent }: Attribute): readonly string[] =>\n when(Array.isReadonlyArrayNonEmpty(parts))(() => [\n `${indent}#[${name}(${pipe(parts, Array.join(\", \"))})]`,\n ]);\n","import { Array, Boolean, Option, pipe } from \"effect\";\n\nimport { distinct, variantIdentifier, variantRule } from \"#/entities/rust-item/index.ts\";\nimport type { Renamed, Enumeration } from \"#/entities/rust-item/index.ts\";\nimport { attribute, docLines, escape } from \"#/shared/lib/text.ts\";\n\nexport interface VariantNaming {\n readonly renameAll: readonly string[];\n readonly perVariant: (value: string) => readonly string[];\n}\n\nexport const variantsOf = (values: readonly string[]): readonly Renamed[] => {\n const names = pipe(values, Array.map(variantIdentifier), distinct(\"\"));\n return pipe(\n values,\n Array.zipWith(names, (value, variant) => ({ variant, value })),\n );\n};\n\nconst ruleFor = (variants: readonly Renamed[]): Option.Option<Option.Option<string>> => {\n const identity = pipe(\n variants,\n Array.every(({ variant, value }) => variant === value),\n );\n return Boolean.match(identity, {\n onTrue: () => Option.some(Option.none()),\n onFalse: () => pipe(variantRule(variants), Option.map(Option.some)),\n });\n};\n\nexport const variantNaming = (variants: readonly Renamed[]): VariantNaming => {\n const rule = ruleFor(variants);\n return {\n renameAll: pipe(\n rule,\n Option.flatten,\n Option.map((name) => `rename_all = \"${name}\"`),\n Option.toArray,\n ),\n perVariant: (value) =>\n Boolean.match(Option.isSome(rule), {\n onTrue: () => [],\n onFalse: () => [`rename = \"${escape(value)}\"`],\n }),\n };\n};\n\nconst ARM = \" \";\n\nconst asStr = (variants: readonly Renamed[]): readonly string[] => [\n \" #[must_use]\",\n \" pub const fn as_str(self) -> &'static str {\",\n \" match self {\",\n ...pipe(\n variants,\n Array.map(({ variant, value }) => `${ARM}Self::${variant} => \"${escape(value)}\",`),\n ),\n \" }\",\n \" }\",\n];\n\nconst parse = (variants: readonly Renamed[]): readonly string[] => [\n \" #[must_use]\",\n \" pub fn parse(value: &str) -> Option<Self> {\",\n \" match value {\",\n ...pipe(\n variants,\n Array.map(({ variant, value }) => `${ARM}\"${escape(value)}\" => Some(Self::${variant}),`),\n ),\n `${ARM}_ => None,`,\n \" }\",\n \" }\",\n];\n\nconst variantLines =\n (naming: VariantNaming) =>\n ({ variant, value }: Renamed): readonly string[] =>\n pipe(\n attribute({ name: \"serde\", parts: naming.perVariant(value), indent: \" \" }),\n Array.append(` ${variant},`),\n );\n\nexport const enumLines =\n (derive: string) =>\n ({ name, doc, values }: Enumeration): readonly string[] => {\n const variants = variantsOf(values);\n const naming = variantNaming(variants);\n return [\n ...docLines(\"\")(doc),\n derive,\n ...attribute({ name: \"serde\", parts: naming.renameAll, indent: \"\" }),\n `pub enum ${name} {`,\n ...pipe(variants, Array.flatMap(variantLines(naming))),\n \"}\",\n \"\",\n `impl ${name} {`,\n ...asStr(variants),\n \"\",\n ...parse(variants),\n \"}\",\n ];\n };\n","import type { Predicate } from \"effect\";\nimport { Array, Match, Option, pipe } from \"effect\";\n\nimport { prim } from \"#/entities/rust-item/index.ts\";\nimport type { Ty } from \"#/entities/rust-item/index.ts\";\n\nconst WIDE_INTEGERS = new Set([\"i64\", \"u64\"]);\nconst SPECTA_NUMBER = \"specta_typescript::Number\";\nconst SPECTA_UNKNOWN = \"specta_typescript::Unknown\";\nconst SINGLE = 1;\n\nconst tupleType = (items: readonly string[]): string =>\n Match.value(items.length).pipe(\n Match.when(SINGLE, () => `(${pipe(items, Array.join(\"\"))},)`),\n Match.orElse(() => `(${pipe(items, Array.join(\", \"))})`),\n );\n\nexport const rustType = (ty: Ty): string =>\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: ({ name }) => name,\n Json: () => \"serde_json::Value\",\n Named: ({ name }) => name,\n Optional: ({ of }) => `Option<${rustType(of)}>`,\n List: ({ of }) => `Vec<${rustType(of)}>`,\n Dictionary: ({ key, value }) => `BTreeMap<${rustType(key)}, ${rustType(value)}>`,\n Tuple: ({ items }) => tupleType(pipe(items, Array.map(rustType))),\n Boxed: ({ of }) => `Box<${rustType(of)}>`,\n }),\n );\n\nexport const spectaType =\n (aliasOf: (name: string) => Option.Option<Ty>) =>\n (ty: Ty): Ty =>\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: ({ name }) =>\n Match.value(WIDE_INTEGERS.has(name)).pipe(\n Match.when(true, () => prim(SPECTA_NUMBER)),\n Match.orElse(() => ty),\n ),\n Json: () => prim(SPECTA_UNKNOWN),\n Named: ({ name }) =>\n pipe(\n aliasOf(name),\n Option.flatMap((target) =>\n Option.liftPredicate(\n spectaType(aliasOf)(target),\n (override) => rustType(override) !== rustType(target),\n ),\n ),\n Option.getOrElse(() => ty),\n ),\n Optional: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n List: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n Boxed: (inner) => ({ ...inner, of: spectaType(aliasOf)(inner.of) }),\n Dictionary: (inner) => ({\n ...inner,\n key: spectaType(aliasOf)(inner.key),\n value: spectaType(aliasOf)(inner.value),\n }),\n Tuple: (inner) => ({ ...inner, items: pipe(inner.items, Array.map(spectaType(aliasOf))) }),\n }),\n );\n\nexport const someTy =\n (predicate: Predicate.Predicate<Ty>) =>\n (ty: Ty): boolean =>\n predicate(ty) ||\n Match.value(ty).pipe(\n Match.tagsExhaustive({\n Prim: () => false,\n Json: () => false,\n Named: () => false,\n Optional: ({ of }) => someTy(predicate)(of),\n List: ({ of }) => someTy(predicate)(of),\n Boxed: ({ of }) => someTy(predicate)(of),\n Dictionary: ({ key, value }) => someTy(predicate)(key) || someTy(predicate)(value),\n Tuple: ({ items }) => pipe(items, Array.some(someTy(predicate))),\n }),\n );\n","import { Array, Boolean, pipe } from \"effect\";\n\nimport { plainIdentifier, serdeCamelField } from \"#/entities/rust-item/index.ts\";\nimport type { Field, Ty } from \"#/entities/rust-item/index.ts\";\nimport { rustType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { attribute, docLines, escape, when } from \"#/shared/lib/text.ts\";\n\nexport interface FieldStyle {\n readonly specta: (ty: Ty) => Ty;\n readonly visibility: string;\n readonly indent: string;\n readonly camel: boolean;\n}\n\nexport const camelCased = (fields: readonly Field[]): boolean =>\n pipe(\n fields,\n Array.some(({ rust, key }) => plainIdentifier(rust) !== key),\n );\n\nconst serdeParts =\n (camel: boolean) =>\n (field: Field): readonly string[] => {\n const plain = plainIdentifier(field.rust);\n const expected = Boolean.match(camel, {\n onTrue: () => serdeCamelField(plain),\n onFalse: () => plain,\n });\n return [\n ...when(expected !== field.key)(() => [`rename = \"${escape(field.key)}\"`]),\n ...when(field.skipNone)(() => ['skip_serializing_if = \"Option::is_none\"']),\n ];\n };\n\nconst spectaParts =\n (style: FieldStyle) =>\n (field: Field): readonly string[] => {\n const override = rustType(style.specta(field.ty));\n return when(override !== rustType(field.ty))(() => [`type = ${override}`]);\n };\n\nexport const fieldLines =\n (style: FieldStyle) =>\n (field: Field): readonly string[] => [\n ...docLines(style.indent)(field.doc),\n ...attribute({ name: \"serde\", parts: serdeParts(style.camel)(field), indent: style.indent }),\n ...attribute({ name: \"specta\", parts: spectaParts(style)(field), indent: style.indent }),\n `${style.indent}${style.visibility}${field.rust}: ${rustType(field.ty)},`,\n ];\n\nexport const renameAllCamel = (camel: boolean): readonly string[] =>\n when(camel)(() => ['rename_all = \"camelCase\"']);\n","import { Array, Match, String, pipe } from \"effect\";\n\nimport type { Item, Struct, Tagged, Ty, Variant } from \"#/entities/rust-item/index.ts\";\nimport { enumLines, variantNaming, variantsOf } from \"#/features/render-rust/model/render-enum.ts\";\nimport {\n camelCased,\n fieldLines,\n renameAllCamel,\n} from \"#/features/render-rust/model/render-fields.ts\";\nimport { rustType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { attribute, docLines, escape } from \"#/shared/lib/text.ts\";\n\nexport interface Style {\n readonly derive: (base: readonly string[]) => string;\n readonly specta: (ty: Ty) => Ty;\n readonly hasFloat: (name: string) => boolean;\n}\n\nconst COMPARABLE = [\"Debug\", \"Clone\", \"PartialEq\"];\nconst EQ = [...COMPARABLE, \"Eq\"];\nconst COPY = [\"Debug\", \"Clone\", \"Copy\", \"PartialEq\", \"Eq\", \"Hash\"];\nconst FIELD = \" \";\nconst VARIANT_FIELD = \" \";\n\nconst dataDerive =\n (style: Style) =>\n (name: string): string =>\n style.derive(\n Match.value(style.hasFloat(name)).pipe(\n Match.when(true, () => COMPARABLE),\n Match.orElse(() => EQ),\n ),\n );\n\nconst struct =\n (style: Style) =>\n (item: Struct): readonly string[] => {\n const camel = camelCased(item.fields);\n const lines = fieldLines({ specta: style.specta, visibility: \"pub \", indent: FIELD, camel });\n return [\n ...docLines(\"\")(item.doc),\n dataDerive(style)(item.name),\n ...attribute({ name: \"serde\", parts: renameAllCamel(camel), indent: \"\" }),\n `pub struct ${item.name} {`,\n ...pipe(item.fields, Array.flatMap(lines)),\n \"}\",\n ];\n };\n\ninterface Laid {\n readonly head: readonly string[];\n readonly name: string;\n readonly fields: readonly (readonly string[])[];\n}\n\nconst STRUCT_VARIANT_WIDTH = 35;\nconst MAX_WIDTH = 100;\nconst ONE_LINE_PUNCTUATION = \" { },\".length;\nconst SINGLE_LINE = 1;\nconst TRAILING_COMMA = /,$/u;\n\nconst laidOut =\n (style: Style, perVariant: (value: string) => readonly string[]) =>\n ([entry, name]: readonly [Variant, string]): Laid => {\n const lines = fieldLines({\n specta: style.specta,\n visibility: \"\",\n indent: VARIANT_FIELD,\n camel: camelCased(entry.fields),\n });\n return {\n head: [\n ...docLines(FIELD)(entry.doc),\n ...attribute({\n name: \"serde\",\n parts: [...perVariant(entry.value), ...renameAllCamel(camelCased(entry.fields))],\n indent: FIELD,\n }),\n ],\n name,\n fields: pipe(entry.fields, Array.map(lines)),\n };\n };\n\nconst oneLineText = ({ fields }: Laid): string =>\n pipe(\n fields,\n Array.flatMap((lines) => lines),\n Array.map((line) => pipe(line, String.trim, String.replace(TRAILING_COMMA, \"\"))),\n Array.join(\", \"),\n );\n\nconst isUnit = ({ fields }: Laid): boolean => Array.isReadonlyArrayEmpty(fields);\n\nconst fitsOneLine = (laid: Laid): boolean => {\n const text = oneLineText(laid);\n const plain = pipe(\n laid.fields,\n Array.every((lines) => lines.length === SINGLE_LINE),\n );\n const width = FIELD.length + laid.name.length + text.length + ONE_LINE_PUNCTUATION;\n return plain && text.length <= STRUCT_VARIANT_WIDTH && width <= MAX_WIDTH;\n};\n\nconst isMultiLine = (laid: Laid): boolean =>\n Array.isReadonlyArrayNonEmpty(laid.head) || (!isUnit(laid) && !fitsOneLine(laid));\n\nconst bodyOf =\n (vertical: boolean) =>\n (laid: Laid): readonly string[] =>\n Match.value({ unit: isUnit(laid), oneLine: !vertical && fitsOneLine(laid) }).pipe(\n Match.when({ unit: true }, () => [`${FIELD}${laid.name},`]),\n Match.when({ oneLine: true }, () => [`${FIELD}${laid.name} { ${oneLineText(laid)} },`]),\n Match.orElse(() => [\n `${FIELD}${laid.name} {`,\n ...pipe(\n laid.fields,\n Array.flatMap((lines) => lines),\n ),\n `${FIELD}},`,\n ]),\n );\n\nconst tagged =\n (style: Style) =>\n (item: Tagged): readonly string[] => {\n const variants = variantsOf(\n pipe(\n item.variants,\n Array.map(({ value }) => value),\n ),\n );\n const naming = variantNaming(variants);\n const laid = pipe(\n item.variants,\n Array.zipWith(variants, (entry, { variant: name }) => [entry, name] as const),\n Array.map(laidOut(style, naming.perVariant)),\n );\n const vertical = pipe(laid, Array.some(isMultiLine)) && !pipe(laid, Array.every(isMultiLine));\n return [\n ...docLines(\"\")(item.doc),\n dataDerive(style)(item.name),\n ...attribute({\n name: \"serde\",\n parts: [`tag = \"${escape(item.tag)}\"`, ...naming.renameAll],\n indent: \"\",\n }),\n `pub enum ${item.name} {`,\n ...pipe(\n laid,\n Array.flatMap((entry) => pipe(entry.head, Array.appendAll(bodyOf(vertical)(entry)))),\n ),\n \"}\",\n ];\n };\n\nexport const itemLines = (style: Style): ((item: Item) => readonly string[]) => {\n const enumeration = enumLines(style.derive(COPY));\n const structure = struct(style);\n const union = tagged(style);\n return (item) =>\n Match.value(item).pipe(\n Match.tagsExhaustive({\n Struct: structure,\n Tagged: union,\n Enumeration: enumeration,\n Alias: ({ name, doc, ty }) => [...docLines(\"\")(doc), `pub type ${name} = ${rustType(ty)};`],\n }),\n );\n};\n","import { Array, Match, Option, Predicate, Record, String, pipe } from \"effect\";\n\nimport { screamingSnakeCase } from \"#/entities/rust-item/index.ts\";\nimport type { Constant, Item, Ty } from \"#/entities/rust-item/index.ts\";\nimport { itemLines } from \"#/features/render-rust/model/render-items.ts\";\nimport { someTy, spectaType } from \"#/features/render-rust/model/rust-type.ts\";\nimport { escape, when } from \"#/shared/lib/text.ts\";\n\nexport interface Rendering {\n readonly header: string;\n readonly derive: readonly string[];\n readonly items: readonly Item[];\n readonly imported: readonly Item[];\n readonly external: Readonly<Record<string, string>>;\n readonly constants: readonly Constant[];\n}\n\nconst SPECTA_TYPE = \"specta::Type\";\nconst PATH_SEPARATOR = \"::\";\n\nconst tysOf = (item: Item): readonly Ty[] =>\n Match.value(item).pipe(\n Match.tagsExhaustive({\n Struct: ({ fields }) =>\n pipe(\n fields,\n Array.map(({ ty }) => ty),\n ),\n Tagged: ({ variants }) =>\n pipe(\n variants,\n Array.flatMap(({ fields }) => fields),\n Array.map(({ ty }) => ty),\n ),\n Enumeration: () => [],\n Alias: ({ ty }) => [ty],\n }),\n );\n\nconst directFloat =\n (isFloat: (name: string) => boolean) =>\n (ty: Ty): boolean =>\n Match.value(ty).pipe(\n Match.tag(\"Prim\", ({ name }) => name === \"f64\"),\n Match.tag(\"Named\", ({ name }) => isFloat(name)),\n Match.orElse(() => false),\n );\n\nconst itemHasFloat = (isFloat: (name: string) => boolean): ((item: Item) => boolean) => {\n const floatTy = someTy(directFloat(isFloat));\n return (item) => pipe(tysOf(item), Array.some(floatTy));\n};\n\nconst floatsIn = (items: readonly Item[]): ((name: string) => boolean) => {\n const byName = new Map(\n pipe(\n items,\n Array.map((item) => [item.name, item] as const),\n ),\n );\n const memo = new Map<string, boolean>();\n const isFloat = (name: string): boolean =>\n pipe(\n Option.fromNullishOr(memo.get(name)),\n Option.getOrElse(() => {\n memo.set(name, false);\n const result = pipe(\n Option.fromNullishOr(byName.get(name)),\n Option.exists(itemHasFloat(isFloat)),\n );\n memo.set(name, result);\n return result;\n }),\n );\n return isFloat;\n};\n\nconst constantLine = ({ name, value }: Constant): string => {\n const rustName = screamingSnakeCase(name);\n return Match.value(value).pipe(\n Match.when(Predicate.isString, (text) => `pub const ${rustName}: &str = \"${escape(text)}\";`),\n Match.when(\n Predicate.isBoolean,\n (flag) => `pub const ${rustName}: bool = ${globalThis.String(flag)};`,\n ),\n Match.when(\n Number.isInteger,\n (count) => `pub const ${rustName}: i64 = ${globalThis.String(count)};`,\n ),\n Match.orElse((amount) => `pub const ${rustName}: f64 = ${globalThis.String(amount)};`),\n );\n};\n\nconst isMap = (ty: Ty): boolean => Predicate.isTagged(ty, \"Dictionary\");\n\nconst usesMap = (items: readonly Item[]): boolean =>\n pipe(items, Array.flatMap(tysOf), Array.some(someTy(isMap)));\n\nconst derivePaths = (derive: readonly string[]): readonly string[] =>\n pipe(derive, Array.filter(String.includes(PATH_SEPARATOR)));\n\nconst namesType =\n (name: string) =>\n (ty: Ty): boolean =>\n Predicate.isTagged(ty, \"Named\") && ty.name === name;\n\nconst usedBy =\n (tys: readonly Ty[]) =>\n ([name]: readonly [string, string]): boolean => {\n const named = someTy(namesType(name));\n return pipe(tys, Array.some(named));\n };\n\nconst usedExternals = ({ items, external }: Rendering): readonly string[] => {\n const used = usedBy(pipe(items, Array.flatMap(tysOf)));\n return pipe(\n Record.toEntries(external),\n Array.filter(used),\n Array.map(([, path]) => path),\n );\n};\n\nconst importLines = (rendering: Rendering): readonly string[] => {\n const { items, derive } = rendering;\n return pipe(\n when(Array.isReadonlyArrayNonEmpty(items))(() => [\n \"serde::{Deserialize, Serialize}\",\n ...derivePaths(derive),\n ...when(usesMap(items))(() => [\"std::collections::BTreeMap\"]),\n ...usedExternals(rendering),\n ]),\n Array.sortBy(String.Order),\n Array.map((path) => `use ${path};`),\n );\n};\n\nconst aliasesOf = (items: readonly Item[]): ReadonlyMap<string, Ty> =>\n new Map(\n pipe(\n items,\n Array.flatMap((item) =>\n Match.value(item).pipe(\n Match.tag(\"Alias\", ({ name, ty }) => [[name, ty] as const]),\n Match.orElse(() => []),\n ),\n ),\n ),\n );\n\nconst spectaOf = ({ derive, items, imported }: Rendering): ((ty: Ty) => Ty) => {\n const aliases = aliasesOf([...items, ...imported]);\n return Match.value(pipe(derive, Array.contains(SPECTA_TYPE))).pipe(\n Match.when(true, () => spectaType((name) => Option.fromNullishOr(aliases.get(name)))),\n Match.orElse(() => (ty: Ty) => ty),\n );\n};\n\nconst shortName = (path: string): string =>\n pipe(path, String.split(PATH_SEPARATOR), Array.lastNonEmpty);\n\nconst deriveLine =\n (extra: readonly string[]) =>\n (base: readonly string[]): string =>\n `#[derive(${pipe([...base, \"Serialize\", \"Deserialize\", ...extra], Array.join(\", \"))})]`;\n\nexport const render = (rendering: Rendering): string => {\n const extra = pipe(rendering.derive, Array.map(shortName));\n const lines = itemLines({\n derive: deriveLine(extra),\n specta: spectaOf(rendering),\n hasFloat: floatsIn([...rendering.items, ...rendering.imported]),\n });\n const sections = pipe(\n [\n [rendering.header],\n importLines(rendering),\n pipe(rendering.constants, Array.map(constantLine)),\n ...pipe(rendering.items, Array.map(lines)),\n ],\n Array.filter(Array.isReadonlyArrayNonEmpty),\n Array.map(Array.join(\"\\n\")),\n );\n return `${pipe(sections, Array.join(\"\\n\\n\"))}\\n`;\n};\n","import { layer as nodeServices } from \"@effect/platform-node/NodeServices\";\nimport {\n Array,\n Effect,\n FileSystem,\n Layer,\n Option,\n Path,\n Predicate,\n Record,\n Schema,\n SchemaAST,\n SchemaRepresentation,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { itemOf, UnsupportedSchema } from \"#/entities/rust-item/index.ts\";\nimport type { Constant } from \"#/entities/rust-item/index.ts\";\nimport {\n copiesOf,\n handWrittenCopies,\n RustFileFailed,\n staleRust,\n} from \"#/features/check-rust/index.ts\";\nimport type { HandWrittenCopies, RustFile, StaleRust } from \"#/features/check-rust/index.ts\";\nimport { render } from \"#/features/render-rust/index.ts\";\n\nexport { UnsupportedSchema } from \"#/entities/rust-item/index.ts\";\nexport { StaleRust } from \"#/features/check-rust/index.ts\";\nexport { HandWrittenCopies, RustFileFailed } from \"#/features/check-rust/index.ts\";\nexport type { RustFile } from \"#/features/check-rust/index.ts\";\n\nexport interface Effect2rsInput {\n readonly definitions: Readonly<Record<string, unknown>>;\n readonly header: string;\n readonly derive?: readonly string[];\n readonly external?: Readonly<Record<string, string>>;\n}\n\nconst isConstant = Predicate.or(\n Predicate.isString,\n Predicate.or(Predicate.isNumber, Predicate.isBoolean),\n);\n\nconst NAMED_BY_EXPORT: readonly Predicate.Predicate<SchemaAST.AST>[] = [\n SchemaAST.isObjects,\n SchemaAST.isUnion,\n SchemaAST.isEnum,\n SchemaAST.isDeclaration,\n SchemaAST.isArrays,\n SchemaAST.isSuspend,\n];\n\nconst namedByExport: Predicate.Predicate<SchemaAST.AST> = (ast) =>\n pipe(\n NAMED_BY_EXPORT,\n Array.some((guard) => guard(ast)),\n );\n\nconst isGenerated: Predicate.Predicate<SchemaAST.AST> = (ast) =>\n namedByExport(ast) || Predicate.isString(SchemaAST.resolveIdentifier(ast));\n\nconst constantOf = ([key, value]: readonly [string, unknown]): Effect.Effect<\n Constant,\n UnsupportedSchema\n> =>\n pipe(\n Option.liftPredicate(value, isConstant),\n Option.match({\n onNone: () =>\n Effect.fail(\n UnsupportedSchema.make({\n path: key,\n reason: \"exports must be schemas, strings, numbers, or booleans\",\n }),\n ),\n onSome: (constant) => Effect.succeed({ name: key, value: constant }),\n }),\n );\n\ninterface Document {\n readonly references: SchemaRepresentation.References;\n readonly chosen: ReadonlySet<string>;\n}\n\nconst schemasOf = (\n definitions: Readonly<Record<string, unknown>>,\n): readonly (readonly [string, Schema.Top])[] =>\n pipe(\n Record.toEntries(definitions),\n Array.filter((entry): entry is [string, Schema.Top] => {\n const [, value] = entry;\n return Schema.isSchema(value);\n }),\n );\n\nconst documentOf = (definitions: Readonly<Record<string, unknown>>): Document => {\n const schemas = schemasOf(definitions);\n const exported = new Map(\n pipe(\n schemas,\n Array.filter(([, schema]) => namedByExport(schema.ast)),\n Array.map(([key, schema]) => [schema.ast, key] as const),\n ),\n );\n const chosen = new Set<string>();\n const policy: SchemaRepresentation.ReferencePolicy = ({ ast, identifier }) =>\n pipe(\n Option.fromNullishOr(identifier),\n Option.orElse(() => Option.fromNullishOr(exported.get(ast))),\n Option.tap((name) => Option.some(chosen.add(name))),\n Option.getOrUndefined,\n );\n const references = pipe(\n schemas,\n Array.map(([, schema]) => schema.ast),\n Array.filter(isGenerated),\n Array.match({\n onEmpty: (): SchemaRepresentation.References => ({}),\n onNonEmpty: (asts) =>\n SchemaRepresentation.toRepresentations(asts, { referencePolicy: policy }).references,\n }),\n );\n return { references, chosen };\n};\n\nconst renamed = (name: string): UnsupportedSchema =>\n UnsupportedSchema.make({\n path: name,\n reason: \"another schema has the same name, or a recursive schema has no identifier\",\n });\n\nexport const effect2rs = Effect.fn(\"effect2rs\")(function* effect2rs(input: Effect2rsInput) {\n const constants = yield* pipe(\n Record.toEntries(input.definitions),\n Array.filter(([, value]) => !Schema.isSchema(value)),\n (items) => Effect.forEach(items, constantOf, { concurrency: 1 }),\n );\n const { references, chosen } = documentOf(input.definitions);\n const named = Record.toEntries(references);\n yield* pipe(\n named,\n Array.findFirst(([name]) => !chosen.has(name)),\n Option.match({\n onNone: () => Effect.void,\n onSome: ([name]) => Effect.fail(renamed(name)),\n }),\n );\n const items = yield* Effect.forEach(named, itemOf(references), { concurrency: 1 });\n const external = input.external ?? {};\n return render({\n header: input.header,\n derive: input.derive ?? [],\n items: pipe(\n items,\n Array.filter(({ name }) => !Record.has(external, name)),\n ),\n imported: pipe(\n items,\n Array.filter(({ name }) => Record.has(external, name)),\n ),\n external,\n constants,\n });\n});\n\nexport interface RustCheck extends Effect2rsInput {\n readonly path: string;\n readonly current: Option.Option<string>;\n readonly siblings: readonly RustFile[];\n}\n\nexport const checkRust = Effect.fn(\"effect2rs.checkRust\")(function* checkRust(check: RustCheck) {\n const source = yield* effect2rs(check);\n yield* pipe(\n check.current,\n Option.filter((current) => current === source),\n Option.match({\n onNone: () => Effect.fail(staleRust(check.path)),\n onSome: () => Effect.void,\n }),\n );\n return yield* pipe(\n copiesOf(source)(check.siblings),\n Array.match({\n onEmpty: () => Effect.void,\n onNonEmpty: (copies) => Effect.fail(handWrittenCopies(copies)),\n }),\n );\n});\n\nexport interface RustOutput extends Effect2rsInput {\n readonly output: string;\n}\n\nconst RUST_FILE = \".rs\";\n\nconst readRust = Effect.fn(\"effect2rs.readRust\")(function* readRust(file: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const source = yield* fileSystem.readFileString(file);\n return { path: file, source };\n});\n\nconst siblingsOf = Effect.fn(\"effect2rs.siblingsOf\")(function* siblingsOf(output: string) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = path.dirname(output);\n const entries = yield* fileSystem.readDirectory(directory, { recursive: true });\n const files = pipe(\n entries,\n Array.filter(Str.endsWith(RUST_FILE)),\n Array.map((entry) => path.join(directory, entry)),\n Array.filter((file) => path.resolve(file) !== path.resolve(output)),\n Array.sortBy(Str.Order),\n );\n return yield* Effect.forEach(files, readRust, { concurrency: 1 });\n});\n\nconst writeRust = Effect.fn(\"effect2rs.writeRust\")(function* writeRust(target: RustOutput) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const source = yield* effect2rs(target);\n yield* fileSystem.makeDirectory(path.dirname(target.output), { recursive: true });\n yield* fileSystem.writeFileString(target.output, source);\n});\n\nconst checkRustOutput = Effect.fn(\"effect2rs.checkRustOutput\")(function* checkRustOutput(\n target: RustOutput,\n) {\n const fileSystem = yield* FileSystem.FileSystem;\n const current = yield* Effect.option(fileSystem.readFileString(target.output));\n const siblings = yield* siblingsOf(target.output);\n yield* checkRust({ ...target, path: target.output, current, siblings });\n});\n\nconst syncOutputs = Effect.fn(\"effect2rs.syncOutputs\")(function* syncOutputs(\n outputs: readonly RustOutput[],\n options: Readonly<{ check: boolean }>,\n) {\n if (options.check) {\n yield* Effect.forEach(outputs, checkRustOutput, { concurrency: 1, discard: true });\n return;\n }\n yield* Effect.forEach(outputs, writeRust, { concurrency: 1, discard: true });\n});\n\nexport type SyncFailure = StaleRust | HandWrittenCopies | UnsupportedSchema | RustFileFailed;\n\nexport const syncRust = (\n outputs: readonly RustOutput[],\n options: Readonly<{ check: boolean }>,\n): Effect.Effect<void, SyncFailure> =>\n Layer.build(nodeServices).pipe(\n Effect.flatMap((services) => Effect.provideContext(syncOutputs(outputs, options), services)),\n Effect.catchTag(\"PlatformError\", ({ message }) =>\n Effect.fail(RustFileFailed.make({ message })),\n ),\n Effect.scoped,\n );\n"],"mappings":";;;AAGA,MAAM,SAAS;AACf,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,UAAU;AAChB,MAAM,UAAU;AAEhB,MAAM,gBAAgB,OAAO,OAAO;CAClC,SAAS,OAAO,YAAY,OAAO,MAAM;CACzC,SAAS,OAAO,YAAY,OAAO,MAAM;CACzC,kBAAkB,OAAO,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;CAClF,kBAAkB,OAAO,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;AACpF,CAAC;AAID,MAAM,gBAAgB,OAAO,oBAAoB,aAAa;AAI9D,MAAM,WACJ,WAEA,KACE,QACA,MAAM,SAAS,UACb,MAAM,MAAM,KAAK,CAAC,CAAC,KACjB,MAAM,eAAe;CACnB,SAAS,WAAW,CAAC,MAAM;CAC3B,cAAc,UAAU,QAAQ,MAAM,MAAM;AAC9C,CAAC,CACH,CACF,CACF;AAEF,MAAM,aACH,UACA,SACC,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK,YAAY,IAAI,GAC3B,MAAM,aAAa,IAAI,CACzB;AAEJ,MAAM,WAAW,WACf,KAAK,QAAQ,MAAM,OAAO,UAAU,QAAQ,CAAC;AAE/C,MAAM,QACH,UACA,YAAwC,CACvC,GAAG,KACD,QAAQ,CAAC,QAAQ,OAA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,CAAC;CAChF,OAAO,WAAW,gBAAgB,OAAO,QAAQ,MAAM;AACzD,CAAC;AAED,MAAM,kBAAkB,OAAO,GAAG,2BAA2B,CAAC,CAAC,UAAU,gBACvE,QACA;CACA,MAAM,aAAa,OAAO,WAAW;CACrC,MAAM,UAAU,OAAO,OAAO,OAAO,WAAW,eAAe,OAAO,MAAM,CAAC;CAC7E,MAAM,WAAW,OAAO,WAAW,OAAO,MAAM;CAChD,OAAO,UAAU;EAAE,GAAG;EAAQ,MAAM,OAAO;EAAQ;EAAS;CAAS,CAAC;AACxE,CAAC;AAED,MAAM,cAAc,OAAO,GAAG,uBAAuB,CAAC,CAAC,UAAU,YAC/D,SACA,SACA;CACA,IAAI,QAAQ,OAAO;EACjB,OAAO,OAAO,QAAQ,SAAS,iBAAiB;GAAE,aAAa;GAAG,SAAS;EAAK,CAAC;EACjF;CACF;CACA,OAAO,OAAO,QAAQ,SAAS,WAAW;EAAE,aAAa;EAAG,SAAS;CAAK,CAAC;AAC7E,CAAC;AAID,MAAa,YACX,SACA,YAEA,MAAM,MAAMC,KAAY,CAAC,CAAC,KACxB,OAAO,SAAS,aAAa,OAAO,eAAe,YAAY,SAAS,OAAO,GAAG,QAAQ,CAAC,GAC3F,OAAO,SAAS,kBAAkB,EAAE,cAClC,OAAO,KAAK,eAAe,KAAK,EAAE,QAAQ,CAAC,CAAC,CAC9C,GACA,OAAO,MACT"}
|
package/dist/plugin-kit.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as readHookInput, i as blockHook, n as runHookWith, o as writeHookOutput, r as HookBlocked, t as runHook } from "./index-CeVmiNfF.mjs";
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
3
3
|
import { Option as Option$1 } from "effect/Option";
|
|
4
4
|
declare const CacheRootError_base: Schema.Class<CacheRootError, Schema.TaggedStruct<"CacheRootError", {
|
|
5
5
|
readonly message: Schema.String;
|
|
@@ -14,5 +14,106 @@ export declare const isRecord: <I>(input: I) => input is I & {
|
|
|
14
14
|
readonly [x: string]: unknown;
|
|
15
15
|
};
|
|
16
16
|
export declare const parseJson: (text: string) => Option$1<unknown>;
|
|
17
|
-
|
|
17
|
+
type Role = "user" | "assistant";
|
|
18
|
+
interface ToolUse {
|
|
19
|
+
readonly tool_use_id: string;
|
|
20
|
+
readonly tool: string;
|
|
21
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
22
|
+
}
|
|
23
|
+
interface ToolResult {
|
|
24
|
+
readonly tool_use_id: string;
|
|
25
|
+
readonly text: string;
|
|
26
|
+
readonly isError: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface Message {
|
|
29
|
+
readonly role: Role;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly toolUses: readonly ToolUse[];
|
|
32
|
+
readonly toolResults: readonly ToolResult[];
|
|
33
|
+
}
|
|
34
|
+
interface ToolCall {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly tool_use_id: string;
|
|
37
|
+
readonly tool: string;
|
|
38
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
39
|
+
readonly callIndex: number;
|
|
40
|
+
readonly resultIndex: number;
|
|
41
|
+
readonly resultChars: number;
|
|
42
|
+
readonly isError: boolean;
|
|
43
|
+
readonly pinned: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface HistoryToolCall {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly tool: string;
|
|
48
|
+
readonly input: string;
|
|
49
|
+
readonly result: string;
|
|
50
|
+
}
|
|
51
|
+
interface HistoryEntry {
|
|
52
|
+
readonly index: number;
|
|
53
|
+
readonly role: Role;
|
|
54
|
+
readonly text: string;
|
|
55
|
+
readonly tool_calls?: readonly HistoryToolCall[] | readonly string[];
|
|
56
|
+
}
|
|
57
|
+
interface CompactionState {
|
|
58
|
+
readonly context: string;
|
|
59
|
+
readonly goal: string;
|
|
60
|
+
readonly history: readonly HistoryEntry[];
|
|
61
|
+
}
|
|
62
|
+
interface FittedState {
|
|
63
|
+
readonly state: CompactionState;
|
|
64
|
+
readonly tokens: number;
|
|
65
|
+
readonly stage: string;
|
|
66
|
+
}
|
|
67
|
+
interface FitOptions {
|
|
68
|
+
readonly maxStateTokens: number;
|
|
69
|
+
readonly preserveRecentMessages: number;
|
|
70
|
+
readonly goal: string;
|
|
71
|
+
}
|
|
72
|
+
export declare const collectToolCalls: (messages: readonly Message[], preserveRecentMessages: number) => readonly ToolCall[];
|
|
73
|
+
declare const HistoryTooLarge_base: Schema.Class<HistoryTooLarge, Schema.TaggedStruct<"HistoryTooLarge", {
|
|
74
|
+
readonly reason: Schema.String;
|
|
75
|
+
}>, import("effect/Cause").YieldableError & {
|
|
76
|
+
readonly brand: unique symbol;
|
|
77
|
+
}>;
|
|
78
|
+
export declare class HistoryTooLarge extends HistoryTooLarge_base {}
|
|
79
|
+
export declare const fitState: (messages: readonly Message[], calls: readonly ToolCall[], options: FitOptions) => Effect.Effect<FittedState, HistoryTooLarge>;
|
|
80
|
+
interface InstalledPlugin {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly installPath: string;
|
|
83
|
+
readonly version: unknown;
|
|
84
|
+
readonly sha: unknown;
|
|
85
|
+
}
|
|
86
|
+
/** @internal */
|
|
87
|
+
export declare const installedPlugins: (home: string) => Effect.Effect<readonly InstalledPlugin[], never, FileSystem.FileSystem | Path.Path>;
|
|
88
|
+
type Place = "ci" | "cloud" | "local";
|
|
89
|
+
interface Origin {
|
|
90
|
+
readonly place: Place;
|
|
91
|
+
readonly project: string;
|
|
92
|
+
readonly hook: string;
|
|
93
|
+
readonly sessionId: string;
|
|
94
|
+
}
|
|
95
|
+
interface JevSettings {
|
|
96
|
+
readonly openRouterKey: string;
|
|
97
|
+
readonly openRouterModel: string;
|
|
98
|
+
readonly allowTraining: boolean;
|
|
99
|
+
readonly attribution: Readonly<Record<string, string>>;
|
|
100
|
+
}
|
|
101
|
+
interface JevBackend {
|
|
102
|
+
readonly apiKey: string;
|
|
103
|
+
readonly baseURL: string;
|
|
104
|
+
readonly model: string;
|
|
105
|
+
readonly extra: Readonly<Record<string, unknown>>;
|
|
106
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
107
|
+
readonly textState: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface PlaceEnv {
|
|
110
|
+
readonly githubActions: string;
|
|
111
|
+
readonly remote: string;
|
|
112
|
+
}
|
|
113
|
+
type JevState = Readonly<Record<string, string>>;
|
|
114
|
+
export declare const placeOf: (env: PlaceEnv) => Place;
|
|
115
|
+
export declare const jevBackend: (settings: JevSettings, origin: Origin) => JevBackend;
|
|
116
|
+
export declare const stateFor: (backend: JevBackend, state: JevState) => JevState | string;
|
|
117
|
+
export declare const estimateTokens: (text: string) => number;
|
|
118
|
+
export { type CompactionState, type FitOptions, type FittedState, type HistoryEntry, type HistoryToolCall, HookBlocked, type InstalledPlugin, type JevBackend, type JevSettings, type JevState, type Message, type Origin, type Place, type PlaceEnv, type Role, type ToolCall, type ToolResult, type ToolUse, blockHook, readHookInput, runHook, runHookWith, writeHookOutput };
|
|
18
119
|
//# sourceMappingURL=plugin-kit.d.mts.map
|
package/dist/plugin-kit.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as runMainWith } from "./run-main-BD4uT8sr.mjs";
|
|
2
|
-
import { Array, Cause, Config, Effect, Layer, Option, Runtime, Schema, Stdio, Stream, pipe } from "effect";
|
|
3
|
-
import { Record as Record$1, String as String$
|
|
2
|
+
import { Array, Cause, Config, Effect, FileSystem, Layer, Number as Number$1, Option, Path, Predicate, Record, Result, Runtime, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
3
|
+
import { Record as Record$1, String as String$2, Unknown, decodeOption, fromJsonString, is } from "effect/Schema";
|
|
4
4
|
// src/shared/lib/cache.ts
|
|
5
|
-
const taggedError$
|
|
6
|
-
var CacheRootError = class extends taggedError$
|
|
5
|
+
const taggedError$2 = Schema.TaggedError;
|
|
6
|
+
var CacheRootError = class extends taggedError$2()("CacheRootError", { message: Schema.String }) {};
|
|
7
7
|
const SEPARATOR = "/";
|
|
8
8
|
const CACHE_DIRECTORY_NAME = ".cache";
|
|
9
9
|
const variable = (name) => Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));
|
|
@@ -19,13 +19,13 @@ const cacheRootEffect = (segments) => baseDirectory.pipe(Effect.flatMap(Option.m
|
|
|
19
19
|
})));
|
|
20
20
|
const cacheRootOf = (segments) => Effect.runPromise(cacheRootEffect(segments));
|
|
21
21
|
// src/shared/lib/record.ts
|
|
22
|
-
const isRecord = is(Record$1(String$
|
|
22
|
+
const isRecord = is(Record$1(String$2, Unknown));
|
|
23
23
|
const parseJson = (text) => decodeOption(fromJsonString(Unknown))(text);
|
|
24
24
|
// src/features/run-main/model/hook-io.ts
|
|
25
25
|
const EXIT_BLOCKING = 2;
|
|
26
|
-
const taggedError = Schema.TaggedError;
|
|
26
|
+
const taggedError$1 = Schema.TaggedError;
|
|
27
27
|
/** @internal */
|
|
28
|
-
var HookBlocked = class extends taggedError()("HookBlocked", { reason: Schema.String }) {
|
|
28
|
+
var HookBlocked = class extends taggedError$1()("HookBlocked", { reason: Schema.String }) {
|
|
29
29
|
[Runtime.errorExitCode] = EXIT_BLOCKING;
|
|
30
30
|
[Runtime.errorReported] = false;
|
|
31
31
|
};
|
|
@@ -73,6 +73,308 @@ const runHook = (serviceName) => runHookWith({
|
|
|
73
73
|
serviceName,
|
|
74
74
|
services: Layer.empty
|
|
75
75
|
});
|
|
76
|
-
|
|
76
|
+
// src/features/fit-history/model/calls.ts
|
|
77
|
+
const FIRST = 0;
|
|
78
|
+
const ONE$3 = 1;
|
|
79
|
+
const ELLIPSIS = "…";
|
|
80
|
+
const VALUE_CHARS = 200;
|
|
81
|
+
const COMPACT_INPUT_CHARS = 60;
|
|
82
|
+
const SPACES = /\s+/gu;
|
|
83
|
+
const encodeJson$1 = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));
|
|
84
|
+
const jsonOf = (value) => encodeJson$1(value);
|
|
85
|
+
const truncate = (text, limit) => {
|
|
86
|
+
if (String$1.length(text) <= limit) return text;
|
|
87
|
+
return `${String$1.slice(FIRST, Math.max(FIRST, limit - ONE$3))(text)}${ELLIPSIS}`;
|
|
88
|
+
};
|
|
89
|
+
const isPinned = (index, total, preserveRecentMessages) => index === FIRST || index >= total - preserveRecentMessages;
|
|
90
|
+
const resultsOf = (messages) => new Map(pipe(messages, Array.flatMap((message, index) => pipe(message.toolResults, Array.map((result) => [result.tool_use_id, {
|
|
91
|
+
index,
|
|
92
|
+
chars: String$1.length(result.text),
|
|
93
|
+
isError: result.isError
|
|
94
|
+
}])))));
|
|
95
|
+
const collectToolCalls = (messages, preserveRecentMessages) => {
|
|
96
|
+
const results = resultsOf(messages);
|
|
97
|
+
const pinned = (index) => isPinned(index, messages.length, preserveRecentMessages);
|
|
98
|
+
return pipe(messages, Array.flatMap((message, callIndex) => pipe(message.toolUses, Array.flatMap((tool) => pipe(Option.fromUndefinedOr(results.get(tool.tool_use_id)), Option.map((found) => ({
|
|
99
|
+
tool,
|
|
100
|
+
callIndex,
|
|
101
|
+
found
|
|
102
|
+
})), Option.toArray)))), Array.map(({ tool, callIndex, found }, index) => ({
|
|
103
|
+
id: `t${String(index + ONE$3)}`,
|
|
104
|
+
tool_use_id: tool.tool_use_id,
|
|
105
|
+
tool: tool.tool,
|
|
106
|
+
input: tool.input,
|
|
107
|
+
callIndex,
|
|
108
|
+
resultIndex: found.index,
|
|
109
|
+
resultChars: found.chars,
|
|
110
|
+
isError: found.isError,
|
|
111
|
+
pinned: pinned(callIndex) || pinned(found.index)
|
|
112
|
+
})));
|
|
113
|
+
};
|
|
114
|
+
const inputText = (input, limit) => truncate(Option.getOrElse(jsonOf(input), () => "[unserializable input]"), limit);
|
|
115
|
+
const outcomeOf = (call) => {
|
|
116
|
+
if (call.isError) return "error";
|
|
117
|
+
return "ok";
|
|
118
|
+
};
|
|
119
|
+
const resultNote = (call) => `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;
|
|
120
|
+
const valueText = ([key, value]) => {
|
|
121
|
+
const text = pipe(Option.liftPredicate(value, (raw) => typeof raw === "string"), Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)));
|
|
122
|
+
return `${key}=${String$1.replaceAll(SPACES, " ")(text)}`;
|
|
123
|
+
};
|
|
124
|
+
const compactCall = (call) => {
|
|
125
|
+
const input = pipe(Record.toEntries(call.input), Array.map(valueText), Array.join(" "));
|
|
126
|
+
return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;
|
|
127
|
+
};
|
|
128
|
+
const callsByMessage = (calls) => new Map(pipe(calls, Array.groupBy((call) => String(call.callIndex)), Record.toEntries, Array.map(([index, own]) => [Number(index), own])));
|
|
129
|
+
const historyCallOf = (inputChars) => (call) => ({
|
|
130
|
+
id: call.id,
|
|
131
|
+
tool: call.tool,
|
|
132
|
+
input: inputText(call.input, inputChars),
|
|
133
|
+
result: resultNote(call)
|
|
134
|
+
});
|
|
135
|
+
const historyEntries = (messages, calls, inputChars) => {
|
|
136
|
+
const byMessage = callsByMessage(calls);
|
|
137
|
+
return pipe(messages, Array.flatMap((message, index) => {
|
|
138
|
+
const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);
|
|
139
|
+
const toolCalls = pipe(own, Array.map(historyCallOf(inputChars)));
|
|
140
|
+
const entry = {
|
|
141
|
+
index,
|
|
142
|
+
role: message.role,
|
|
143
|
+
text: message.text
|
|
144
|
+
};
|
|
145
|
+
if (Array.isReadonlyArrayNonEmpty(toolCalls)) return [{
|
|
146
|
+
...entry,
|
|
147
|
+
tool_calls: toolCalls
|
|
148
|
+
}];
|
|
149
|
+
if (String$1.isEmpty(String$1.trim(message.text))) return [];
|
|
150
|
+
return [entry];
|
|
151
|
+
}));
|
|
152
|
+
};
|
|
153
|
+
// src/shared/lib/tokens.ts
|
|
154
|
+
const PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\d+)|(?<other>[^\sA-Za-z\d])/gu;
|
|
155
|
+
const DIGITS_PER_TOKEN = 2;
|
|
156
|
+
const LETTERS_PER_TOKEN = 6;
|
|
157
|
+
const SYMBOL_TOKENS = .9;
|
|
158
|
+
const ONE$2 = 1;
|
|
159
|
+
const groupOf = (match, key) => pipe(Option.fromUndefinedOr(match.groups), Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])));
|
|
160
|
+
const pieceTokens = (match) => pipe(groupOf(match, "digits"), Option.map((digits) => String$1.length(digits) / DIGITS_PER_TOKEN), Option.orElse(() => Option.map(groupOf(match, "alpha"), (alpha) => ONE$2 + Math.floor((String$1.length(alpha) - ONE$2) / LETTERS_PER_TOKEN))), Option.getOrElse(() => SYMBOL_TOKENS));
|
|
161
|
+
const matchesOf = (pattern, text) => Array.fromIterable(String$1.matchAll(pattern)(text));
|
|
162
|
+
const estimateTokens = (text) => {
|
|
163
|
+
const pieces = pipe(matchesOf(PIECES, text), Array.map(pieceTokens));
|
|
164
|
+
return Math.ceil(Number$1.sumAll(pieces));
|
|
165
|
+
};
|
|
166
|
+
// src/features/fit-history/model/fitting.ts
|
|
167
|
+
const ONE$1 = 1;
|
|
168
|
+
const NONE = 0;
|
|
169
|
+
const entryTokens = (entry) => estimateTokens(Option.getOrElse(jsonOf(entry), () => "")) + ONE$1;
|
|
170
|
+
const fittingOf = (plan, history) => {
|
|
171
|
+
const perEntry = pipe(history, Array.map(entryTokens));
|
|
172
|
+
return {
|
|
173
|
+
history: pipe(history, Array.map(Option.some)),
|
|
174
|
+
perEntry,
|
|
175
|
+
tokens: plan.baseTokens + Number$1.sumAll(perEntry)
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
const kept = (fitting) => Array.getSomes(fitting.history);
|
|
179
|
+
const fits = (plan, fitting) => fitting.tokens <= plan.options.maxStateTokens;
|
|
180
|
+
const fitted = (plan, fitting, stage) => ({
|
|
181
|
+
state: plan.stateOf(kept(fitting)),
|
|
182
|
+
tokens: fitting.tokens,
|
|
183
|
+
stage
|
|
184
|
+
});
|
|
185
|
+
const pinnedEntry = (plan, entry) => isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);
|
|
186
|
+
const orderOf = (plan, fitting) => {
|
|
187
|
+
const present = pipe(fitting.history, Array.flatMap((entry, index) => pipe(entry, Option.map((value) => [index, pinnedEntry(plan, value)]), Option.toArray)));
|
|
188
|
+
const loose = pipe(present, Array.filter(([, pinned]) => !pinned));
|
|
189
|
+
const pinned = pipe(present, Array.filter(([, isPinnedEntry]) => isPinnedEntry));
|
|
190
|
+
return pipe([...loose, ...pinned], Array.map(([index]) => index));
|
|
191
|
+
};
|
|
192
|
+
const stepOf = (fitting, change) => (index) => pipe(Option.flatten(Option.fromUndefinedOr(fitting.history[index])), Option.flatMap(change), Option.map((entry) => ({
|
|
193
|
+
index,
|
|
194
|
+
entry,
|
|
195
|
+
tokens: Option.match(entry, {
|
|
196
|
+
onNone: () => NONE,
|
|
197
|
+
onSome: entryTokens
|
|
198
|
+
})
|
|
199
|
+
})));
|
|
200
|
+
const applied = (fitting, steps) => {
|
|
201
|
+
const byIndex = new Map(pipe(steps, Array.map((step) => [step.index, step])));
|
|
202
|
+
const pick = (index, value, of) => Option.match(Option.fromUndefinedOr(byIndex.get(index)), {
|
|
203
|
+
onNone: () => value,
|
|
204
|
+
onSome: of
|
|
205
|
+
});
|
|
206
|
+
const history = pipe(fitting.history, Array.map((entry, index) => pick(index, entry, (step) => step.entry)));
|
|
207
|
+
const perEntry = pipe(fitting.perEntry, Array.map((tokens, index) => pick(index, tokens, (step) => step.tokens)));
|
|
208
|
+
const delta = Number$1.sumAll(pipe(steps, Array.map((step) => step.tokens - Option.getOrElse(Array.get(fitting.perEntry, step.index), () => NONE))));
|
|
209
|
+
return {
|
|
210
|
+
history,
|
|
211
|
+
perEntry,
|
|
212
|
+
tokens: fitting.tokens + delta
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
const staged = (plan, fitting, change) => {
|
|
216
|
+
const steps = pipe(orderOf(plan, fitting), Array.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))));
|
|
217
|
+
const totals = pipe(steps, Array.scan(fitting.tokens, (tokens, step) => tokens + step.tokens - Option.getOrElse(Array.get(fitting.perEntry, step.index), () => NONE)), Array.drop(ONE$1));
|
|
218
|
+
return Option.match(Array.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens), {
|
|
219
|
+
onNone: () => [applied(fitting, steps), false],
|
|
220
|
+
onSome: (at) => [applied(fitting, Array.take(steps, at + ONE$1)), true]
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
// src/features/fit-history/model/state.ts
|
|
224
|
+
const STATE_CONTEXT = "A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.";
|
|
225
|
+
const taggedError = Schema.TaggedError;
|
|
226
|
+
var HistoryTooLarge = class extends taggedError()("HistoryTooLarge", { reason: Schema.String }) {};
|
|
227
|
+
const FULL_INPUT_CHARS = 1e3;
|
|
228
|
+
const SHORTER_INPUT_CHARS = [200, 60];
|
|
229
|
+
const TEXT_HEAD = 400;
|
|
230
|
+
const TEXT_TAIL = 150;
|
|
231
|
+
const RECENT_GOALS = 3;
|
|
232
|
+
const GOAL_CHARS = 500;
|
|
233
|
+
const ONE = 1;
|
|
234
|
+
const abridge = (text) => {
|
|
235
|
+
const omitted = String$1.length(text) - TEXT_HEAD - TEXT_TAIL;
|
|
236
|
+
return `${String$1.takeLeft(TEXT_HEAD)(text)}\n[… ${String(omitted)} chars omitted …]\n${String$1.takeRight(TEXT_TAIL)(text)}`;
|
|
237
|
+
};
|
|
238
|
+
const goalFromMessages = (messages) => pipe(messages, Array.filter((message) => message.role === "user" && String$1.isNonEmpty(String$1.trim(message.text)) && Array.isReadonlyArrayEmpty(message.toolResults)), Array.takeRight(RECENT_GOALS), Array.map((message) => truncate(message.text, GOAL_CHARS)), Array.join("\n"));
|
|
239
|
+
const abridgeText = (entry) => Option.liftPredicate(Option.some({
|
|
240
|
+
...entry,
|
|
241
|
+
text: abridge(entry.text)
|
|
242
|
+
}), () => String$1.length(entry.text) > 590);
|
|
243
|
+
const collapseText = (plan) => (entry) => {
|
|
244
|
+
const original = pipe(Array.get(plan.messages, entry.index), Option.map((message) => String$1.length(message.text)), Option.getOrElse(() => String$1.length(entry.text)));
|
|
245
|
+
return Option.liftPredicate(Option.some({
|
|
246
|
+
...entry,
|
|
247
|
+
text: `[… ${String(original)} chars omitted …]`
|
|
248
|
+
}), () => !pinnedEntry(plan, entry) && String$1.isNonEmpty(entry.text));
|
|
249
|
+
};
|
|
250
|
+
const compactCalls = (plan) => (entry) => pipe(Option.fromUndefinedOr(plan.byMessage.get(entry.index)), Option.filter(() => !pinnedEntry(plan, entry)), Option.map((own) => Option.some({
|
|
251
|
+
...entry,
|
|
252
|
+
tool_calls: pipe(own, Array.map(compactCall))
|
|
253
|
+
})));
|
|
254
|
+
const leaveOut = (plan) => (entry) => Option.liftPredicate(Option.none(), () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls));
|
|
255
|
+
const callsOf = (entry) => Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);
|
|
256
|
+
const stringCalls = (entry) => pipe(callsOf(entry), Array.filter(Predicate.isString));
|
|
257
|
+
const foldable = (plan, entry) => !pinnedEntry(plan, entry) && String$1.isEmpty(entry.text) && pipe(Array.head(callsOf(entry)), Option.exists(Predicate.isString));
|
|
258
|
+
const mergedRun = (group) => {
|
|
259
|
+
const first = Array.headNonEmpty(group);
|
|
260
|
+
if (group.length === ONE) return first;
|
|
261
|
+
return {
|
|
262
|
+
...first,
|
|
263
|
+
tool_calls: pipe(group, Array.flatMap(stringCalls))
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
const mergeRuns = (plan, history) => {
|
|
267
|
+
if (!Array.isReadonlyArrayNonEmpty(history)) return [];
|
|
268
|
+
return pipe(Array.groupWith(history, (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role), Array.map(mergedRun));
|
|
269
|
+
};
|
|
270
|
+
const rebuilt = (plan, inputChars) => () => {
|
|
271
|
+
const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));
|
|
272
|
+
return [fitting, fits(plan, fitting)];
|
|
273
|
+
};
|
|
274
|
+
const stagesOf = (plan) => [
|
|
275
|
+
...pipe(SHORTER_INPUT_CHARS, Array.map((limit) => [`inputs<=${String(limit)}`, rebuilt(plan, limit)])),
|
|
276
|
+
["texts abridged", (fitting) => staged(plan, fitting, abridgeText)],
|
|
277
|
+
["old messages collapsed", (fitting) => staged(plan, fitting, collapseText(plan))],
|
|
278
|
+
["old calls compacted", (fitting) => staged(plan, fitting, compactCalls(plan))],
|
|
279
|
+
["old messages left out", (fitting) => staged(plan, fitting, leaveOut(plan))],
|
|
280
|
+
["old calls merged", (fitting) => {
|
|
281
|
+
const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));
|
|
282
|
+
return [merged, fits(plan, merged)];
|
|
283
|
+
}]
|
|
284
|
+
];
|
|
285
|
+
const throughStages = (plan, fitting, stages) => Option.match(Array.head(stages), {
|
|
286
|
+
onNone: () => Result.fail(fitting),
|
|
287
|
+
onSome: ([name, run]) => {
|
|
288
|
+
const [next, done] = run(fitting);
|
|
289
|
+
if (done) return Result.succeed(fitted(plan, next, name));
|
|
290
|
+
return throughStages(plan, next, Array.drop(stages, ONE));
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
const jsonText = (value) => Option.getOrElse(jsonOf(value), () => "");
|
|
294
|
+
const planOf = (messages, calls, options) => {
|
|
295
|
+
const goal = pipe(Option.liftPredicate(options.goal, String$1.isNonEmpty), Option.getOrElse(() => goalFromMessages(messages)));
|
|
296
|
+
const stateOf = (history) => ({
|
|
297
|
+
context: STATE_CONTEXT,
|
|
298
|
+
goal,
|
|
299
|
+
history
|
|
300
|
+
});
|
|
301
|
+
return {
|
|
302
|
+
messages,
|
|
303
|
+
calls,
|
|
304
|
+
options,
|
|
305
|
+
stateOf,
|
|
306
|
+
baseTokens: estimateTokens(jsonText(stateOf([]))),
|
|
307
|
+
byMessage: callsByMessage(calls)
|
|
308
|
+
};
|
|
309
|
+
};
|
|
310
|
+
const fitState = (messages, calls, options) => {
|
|
311
|
+
const plan = planOf(messages, calls, options);
|
|
312
|
+
const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));
|
|
313
|
+
if (fits(plan, full)) return Effect.succeed(fitted(plan, full, "full"));
|
|
314
|
+
return Result.match(throughStages(plan, full, stagesOf(plan)), {
|
|
315
|
+
onSuccess: Effect.succeed,
|
|
316
|
+
onFailure: (last) => Effect.fail(HistoryTooLarge.make({ reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})` }))
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
// src/shared/lib/installed-plugins.ts
|
|
320
|
+
const InstalledEntry = Schema.Struct({
|
|
321
|
+
installPath: Schema.String,
|
|
322
|
+
version: Schema.Unknown,
|
|
323
|
+
gitCommitSha: Schema.Unknown
|
|
324
|
+
});
|
|
325
|
+
const InstalledPlugins = Schema.Struct({ plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)) });
|
|
326
|
+
const decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));
|
|
327
|
+
const flattened = (installed) => pipe(Record.toEntries(installed.plugins), Array.flatMap(([id, entries]) => pipe(entries, Array.map((entry) => ({
|
|
328
|
+
id,
|
|
329
|
+
installPath: entry.installPath,
|
|
330
|
+
version: entry.version,
|
|
331
|
+
sha: entry.gitCommitSha
|
|
332
|
+
})))));
|
|
333
|
+
/** @internal */
|
|
334
|
+
const installedPlugins = Effect.fn("installedPlugins")(function* installedPlugins(home) {
|
|
335
|
+
const fs = yield* FileSystem.FileSystem;
|
|
336
|
+
const file = (yield* Path.Path).join(home, ".claude", "plugins", "installed_plugins.json");
|
|
337
|
+
return yield* fs.readFileString(file).pipe(Effect.flatMap(decodeInstalled), Effect.map(flattened), Effect.orElseSucceed(() => []));
|
|
338
|
+
});
|
|
339
|
+
// src/shared/lib/jev-backend.ts
|
|
340
|
+
const DEFAULT_OPENROUTER_MODEL = "respan/span-01-lite";
|
|
341
|
+
const TEXT_STATE_PREFIX = "respan/";
|
|
342
|
+
const encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));
|
|
343
|
+
const placeOf = (env) => {
|
|
344
|
+
if (env.githubActions === "true") return "ci";
|
|
345
|
+
if (env.remote === "true") return "cloud";
|
|
346
|
+
return "local";
|
|
347
|
+
};
|
|
348
|
+
const dataCollection = (allowTraining) => {
|
|
349
|
+
if (allowTraining) return "allow";
|
|
350
|
+
return "deny";
|
|
351
|
+
};
|
|
352
|
+
const jevBackend = (settings, origin) => {
|
|
353
|
+
const model = pipe(Option.liftPredicate(settings.openRouterModel, String$1.isNonEmpty), Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL));
|
|
354
|
+
const session = pipe(Option.liftPredicate(origin.sessionId, String$1.isNonEmpty), Option.match({
|
|
355
|
+
onNone: () => ({}),
|
|
356
|
+
onSome: (id) => ({ session_id: id })
|
|
357
|
+
}));
|
|
358
|
+
return {
|
|
359
|
+
apiKey: settings.openRouterKey,
|
|
360
|
+
baseURL: "https://openrouter.ai/api",
|
|
361
|
+
model,
|
|
362
|
+
extra: {
|
|
363
|
+
provider: { data_collection: dataCollection(settings.allowTraining) },
|
|
364
|
+
user: `${origin.place}:${origin.project}:${origin.hook}`,
|
|
365
|
+
...session
|
|
366
|
+
},
|
|
367
|
+
headers: settings.attribution,
|
|
368
|
+
textState: String$1.startsWith(TEXT_STATE_PREFIX)(model)
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
const sectionOf = ([key, value]) => {
|
|
372
|
+
return `## ${key}\n${pipe(Option.liftPredicate(value, Predicate.isString), Option.orElse(() => encodeJson(value)), Option.getOrElse(() => ""))}`;
|
|
373
|
+
};
|
|
374
|
+
const stateFor = (backend, state) => {
|
|
375
|
+
if (!backend.textState) return state;
|
|
376
|
+
return pipe(Record.toEntries(state), Array.map(sectionOf), Array.join("\n\n"));
|
|
377
|
+
};
|
|
378
|
+
export { CACHE_DIRECTORY_NAME, CacheRootError, HistoryTooLarge, HookBlocked, blockHook, cacheRootEffect, cacheRootOf, collectToolCalls, estimateTokens, fitState, installedPlugins, isRecord, jevBackend, parseJson, placeOf, readHookInput, runHook, runHookWith, stateFor, writeHookOutput };
|
|
77
379
|
|
|
78
380
|
//# sourceMappingURL=plugin-kit.mjs.map
|
package/dist/plugin-kit.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-kit.mjs","names":["taggedError","Arr","RecordSchema","StringSchema"],"sources":["../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts"],"sourcesContent":["import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n"],"mappings":";;;;AAEA,MAAMA,gBAAc,OAAO;AAE3B,IAAa,iBAAb,cAAoCA,cAGlC,CAAC,CAAC,kBAAkB,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAM,YAAY;AAClB,MAAa,uBAAuB;AAEpC,MAAM,YAAY,SAChB,OAAO,OAAO,OAAO,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,OAAO,IAAI,CAAC;AAEnF,MAAM,gBAAsD,OAAO,IAAI,UAAU,gBAAgB;CAC/F,MAAM,YAAY,OAAO,SAAS,gBAAgB;CAClD,MAAM,OAAO,OAAO,SAAS,MAAM;CACnC,MAAM,UAAU,OAAO,SAAS,aAAa;CAC7C,OAAO,KACL,WACA,OAAO,aACL,KACE,OAAO,OAAO,YAAY,OAAO,GACjC,OAAO,KAAK,cAAc,GAAG,YAAY,YAAY,sBAAsB,CAC7E,CACF,CACF;AACF,CAAC;AAED,MAAa,mBACX,aAEA,cAAc,KACZ,OAAO,QACL,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,eAAe,KAAK,EAAE,SAAS,6BAA6B,CAAC,CAAC;CACxF,SAAS,SAAS,OAAO,QAAQ,KAAK,CAAC,MAAM,GAAG,QAAQ,GAAGC,MAAI,KAAK,SAAS,CAAC,CAAC;AACjF,CAAC,CACH,CACF;AAEF,MAAa,eAAe,aAC1B,OAAO,WAAW,gBAAgB,QAAQ,CAAC;;ACjC7C,MAAa,WAAW,GAAGC,SAAaC,UAAc,OAAO,CAAC;AAE9D,MAAa,aAAa,SACxB,aAAa,eAAe,OAAO,CAAC,CAAC,CAAC,IAAI;;ACX5C,MAAM,gBAAgB;AAEtB,MAAM,cAAc,OAAO;;AAG3B,IAAa,cAAb,cAAiC,YAA4D,CAAC,CAC5F,eACA,E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AK,GAAG;CAC7B,cAAc,OAAO;CACrB,SAAS,YAAY,YAAY,GAAG,QAAQ,OAAO,GAAG;AACxD,CAAC;;AAGH,MAAa,eACc,EACvB,aACA,gBAKD,YAAY;CACX,YAAY;EAAE;EAAa;CAAS,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,SAAS,aAAa,CAAC,CAAC;AACrF;;AAGF,MAAa,WAAW,gBACtB,YAAY;CAAE;CAAa,UAAU,MAAM;AAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"plugin-kit.mjs","names":["taggedError","Arr","RecordSchema","StringSchema","taggedError","ONE","encodeJson","Str","Arr","Rec","ONE","Str","Arr","Num","ONE","Arr","Num","Str","Arr","Rec","Arr","Str","Rec","Arr"],"sources":["../src/shared/lib/cache.ts","../src/shared/lib/record.ts","../src/features/run-main/model/hook-io.ts","../src/features/run-main/model/run-hook.ts","../src/features/fit-history/model/calls.ts","../src/shared/lib/tokens.ts","../src/features/fit-history/model/fitting.ts","../src/features/fit-history/model/state.ts","../src/shared/lib/installed-plugins.ts","../src/shared/lib/jev-backend.ts"],"sourcesContent":["import { Array as Arr, Config, Effect, Option, Schema, pipe } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class CacheRootError extends taggedError<\n CacheRootError,\n { readonly brand: unique symbol }\n>()(\"CacheRootError\", { message: Schema.String }) {}\n\nconst SEPARATOR = \"/\";\nexport const CACHE_DIRECTORY_NAME = \".cache\";\n\nconst variable = (name: string): Effect.Effect<Option.Option<string>> =>\n Config.option(Config.NonEmptyString(name)).pipe(Effect.orElseSucceed(Option.none));\n\nconst baseDirectory: Effect.Effect<Option.Option<string>> = Effect.gen(function* baseDirectory() {\n const cacheHome = yield* variable(\"XDG_CACHE_HOME\");\n const home = yield* variable(\"HOME\");\n const profile = yield* variable(\"USERPROFILE\");\n return pipe(\n cacheHome,\n Option.orElse(() =>\n pipe(\n Option.orElse(home, () => profile),\n Option.map((directory) => `${directory}${SEPARATOR}${CACHE_DIRECTORY_NAME}`),\n ),\n ),\n );\n});\n\nexport const cacheRootEffect = (\n segments: readonly string[],\n): Effect.Effect<string, CacheRootError> =>\n baseDirectory.pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.fail(CacheRootError.make({ message: \"set XDG_CACHE_HOME or HOME\" })),\n onSome: (base) => Effect.succeed(pipe([base, ...segments], Arr.join(SEPARATOR))),\n }),\n ),\n );\n\nexport const cacheRootOf = (segments: readonly string[]): Promise<string> =>\n Effect.runPromise(cacheRootEffect(segments));\n","import type { Option } from \"effect/Option\";\nimport {\n Record as RecordSchema,\n String as StringSchema,\n Unknown,\n decodeOption,\n fromJsonString,\n is,\n} from \"effect/Schema\";\n\nexport const isRecord = is(RecordSchema(StringSchema, Unknown));\n\nexport const parseJson = (text: string): Option<unknown> =>\n decodeOption(fromJsonString(Unknown))(text);\n","import { Effect, Runtime, Schema, Stdio, Stream } from \"effect\";\n\nconst EXIT_BLOCKING = 2;\n\nconst taggedError = Schema.TaggedError;\n\n/** @internal */\nexport class HookBlocked extends taggedError<HookBlocked, { readonly brand: unique symbol }>()(\n \"HookBlocked\",\n { reason: Schema.String },\n) {\n public override readonly [Runtime.errorExitCode] = EXIT_BLOCKING;\n public override readonly [Runtime.errorReported] = false;\n}\n\n/** @internal */\nexport const isHookBlocked = Schema.is(HookBlocked);\n\n/** @internal */\nexport const blockHook = (reason: string): Effect.Effect<never, HookBlocked> =>\n Effect.fail(HookBlocked.make({ reason }));\n\n/** @internal */\nexport const readStdin: Effect.Effect<string, never, Stdio.Stdio> = Effect.gen(\n function* readStdin() {\n const stdio = yield* Stdio.Stdio;\n return yield* stdio.stdin.pipe(Stream.decodeText, Stream.mkString, Effect.orDie);\n },\n);\n\n/** @internal */\nexport const readHookInput = <Codec extends Schema.Top>(\n schema: Codec,\n): Effect.Effect<Codec[\"Type\"], Schema.SchemaError, Stdio.Stdio | Codec[\"DecodingServices\"]> =>\n Effect.gen(function* read() {\n const text = yield* readStdin;\n const json = Schema.fromJsonString(schema);\n return yield* Schema.decodeEffect(json)(text);\n });\n\n/** @internal */\nexport const writeStdout = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStdout() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeStderr = (text: string): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* toStderr() {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\n/** @internal */\nexport const writeHookOutput =\n <Codec extends Schema.Top>(schema: Codec) =>\n (value: Codec[\"Type\"]): Effect.Effect<void, never, Stdio.Stdio | Codec[\"EncodingServices\"]> =>\n Schema.encodeEffect(Schema.fromJsonString(schema))(value).pipe(\n Effect.orDie,\n Effect.flatMap(writeStdout),\n );\n","import { Cause, Effect, Layer, Option } from \"effect\";\nimport type { Stdio } from \"effect\";\n\nimport { isHookBlocked, writeStderr } from \"./hook-io.ts\";\nimport type { HookBlocked } from \"./hook-io.ts\";\nimport { runMainWith } from \"./run-main.ts\";\nimport type { Platform, Run } from \"./run-main.ts\";\n\nconst blockedIn = <Failure>(cause: Cause.Cause<Failure>): Option.Option<HookBlocked> =>\n Cause.findErrorOption(cause).pipe(\n Option.filter((error): error is Failure & HookBlocked => isHookBlocked(error)),\n );\n\nconst reportBlocked = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Option.match(blockedIn(cause), {\n onNone: () => Effect.void,\n onSome: (blocked) => writeStderr(`${blocked.reason}\\n`),\n });\n\n/** @internal */\nexport const runHookWith =\n <Provided, LayerFailure>({\n serviceName,\n services,\n }: Readonly<{\n serviceName: string;\n services: Layer.Layer<Provided, LayerFailure, Platform>;\n }>): Run<Provided> =>\n (program) => {\n runMainWith({ serviceName, services })(program.pipe(Effect.tapCause(reportBlocked)));\n };\n\n/** @internal */\nexport const runHook = (serviceName: string): Run<never> =>\n runHookWith({ serviceName, services: Layer.empty });\n","import { Array as Arr, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport type { HistoryEntry, HistoryToolCall, Message, ToolCall } from \"./types.ts\";\n\nconst FIRST = 0;\nconst ONE = 1;\nconst ELLIPSIS = \"…\";\nconst VALUE_CHARS = 200;\nconst COMPACT_INPUT_CHARS = 60;\nconst SPACES = /\\s+/gu;\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const jsonOf = (value: unknown): Option.Option<string> => encodeJson(value);\n\nexport const truncate = (text: string, limit: number): string => {\n if (Str.length(text) <= limit) {\n return text;\n }\n return `${Str.slice(FIRST, Math.max(FIRST, limit - ONE))(text)}${ELLIPSIS}`;\n};\n\nexport const isPinned = (index: number, total: number, preserveRecentMessages: number): boolean =>\n index === FIRST || index >= total - preserveRecentMessages;\n\ninterface Found {\n readonly index: number;\n readonly chars: number;\n readonly isError: boolean;\n}\n\nconst resultsOf = (messages: readonly Message[]): ReadonlyMap<string, Found> =>\n new Map(\n pipe(\n messages,\n Arr.flatMap((message, index) =>\n pipe(\n message.toolResults,\n Arr.map(\n (result) =>\n [\n result.tool_use_id,\n { index, chars: Str.length(result.text), isError: result.isError },\n ] as const,\n ),\n ),\n ),\n ),\n );\n\nexport const collectToolCalls = (\n messages: readonly Message[],\n preserveRecentMessages: number,\n): readonly ToolCall[] => {\n const results = resultsOf(messages);\n const pinned = (index: number): boolean =>\n isPinned(index, messages.length, preserveRecentMessages);\n return pipe(\n messages,\n Arr.flatMap((message, callIndex) =>\n pipe(\n message.toolUses,\n Arr.flatMap((tool) =>\n pipe(\n Option.fromUndefinedOr(results.get(tool.tool_use_id)),\n Option.map((found) => ({ tool, callIndex, found })),\n Option.toArray,\n ),\n ),\n ),\n ),\n Arr.map(({ tool, callIndex, found }, index) => ({\n id: `t${String(index + ONE)}`,\n tool_use_id: tool.tool_use_id,\n tool: tool.tool,\n input: tool.input,\n callIndex,\n resultIndex: found.index,\n resultChars: found.chars,\n isError: found.isError,\n pinned: pinned(callIndex) || pinned(found.index),\n })),\n );\n};\n\nexport const inputText = (input: Readonly<Record<string, unknown>>, limit: number): string =>\n truncate(\n Option.getOrElse(jsonOf(input), () => \"[unserializable input]\"),\n limit,\n );\n\nconst outcomeOf = (call: ToolCall): string => {\n if (call.isError) {\n return \"error\";\n }\n return \"ok\";\n};\n\nconst resultNote = (call: ToolCall): string =>\n `${outcomeOf(call)}, ${String(call.resultChars)} chars (omitted)`;\n\nconst valueText = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, (raw): raw is string => typeof raw === \"string\"),\n Option.getOrElse(() => inputText({ [key]: value }, VALUE_CHARS)),\n );\n return `${key}=${Str.replaceAll(SPACES, \" \")(text)}`;\n};\n\nexport const compactCall = (call: ToolCall): string => {\n const input = pipe(Rec.toEntries(call.input), Arr.map(valueText), Arr.join(\" \"));\n return `${call.id} ${call.tool} ${truncate(input, COMPACT_INPUT_CHARS)} → ${outcomeOf(call)} ${String(call.resultChars)}ch`;\n};\n\nexport const callsByMessage = (\n calls: readonly ToolCall[],\n): ReadonlyMap<number, readonly ToolCall[]> =>\n new Map(\n pipe(\n calls,\n Arr.groupBy((call) => String(call.callIndex)),\n Rec.toEntries,\n Arr.map(([index, own]) => [Number(index), own] as const),\n ),\n );\n\nconst historyCallOf =\n (inputChars: number) =>\n (call: ToolCall): HistoryToolCall => ({\n id: call.id,\n tool: call.tool,\n input: inputText(call.input, inputChars),\n result: resultNote(call),\n });\n\nexport const historyEntries = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n inputChars: number,\n): readonly HistoryEntry[] => {\n const byMessage = callsByMessage(calls);\n return pipe(\n messages,\n Arr.flatMap((message, index): readonly HistoryEntry[] => {\n const own = Option.getOrElse(Option.fromUndefinedOr(byMessage.get(index)), () => []);\n const toolCalls = pipe(own, Arr.map(historyCallOf(inputChars)));\n const entry = { index, role: message.role, text: message.text };\n if (Arr.isReadonlyArrayNonEmpty(toolCalls)) {\n return [{ ...entry, tool_calls: toolCalls }];\n }\n if (Str.isEmpty(Str.trim(message.text))) {\n return [];\n }\n return [entry];\n }),\n );\n};\n","import { Array as Arr, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nconst PIECES = /(?<alpha>[A-Za-z]+)|(?<digits>\\d+)|(?<other>[^\\sA-Za-z\\d])/gu;\nconst DIGITS_PER_TOKEN = 2;\nconst LETTERS_PER_TOKEN = 6;\nconst SYMBOL_TOKENS = 0.9;\nconst ONE = 1;\n\nconst groupOf = (match: RegExpMatchArray, key: string): Option.Option<string> =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[key])),\n );\n\nconst pieceTokens = (match: RegExpMatchArray): number =>\n pipe(\n groupOf(match, \"digits\"),\n Option.map((digits) => Str.length(digits) / DIGITS_PER_TOKEN),\n Option.orElse(() =>\n Option.map(\n groupOf(match, \"alpha\"),\n (alpha) => ONE + Math.floor((Str.length(alpha) - ONE) / LETTERS_PER_TOKEN),\n ),\n ),\n Option.getOrElse(() => SYMBOL_TOKENS),\n );\n\nconst matchesOf = (pattern: RegExp, text: string): readonly RegExpMatchArray[] =>\n Arr.fromIterable(Str.matchAll(pattern)(text));\n\nexport const estimateTokens = (text: string): number => {\n const pieces = pipe(matchesOf(PIECES, text), Arr.map(pieceTokens));\n return Math.ceil(Num.sumAll(pieces));\n};\n","import { Array as Arr, Number as Num, Option, pipe } from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { isPinned, jsonOf } from \"./calls.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nconst ONE = 1;\nconst NONE = 0;\n\nexport const entryTokens = (entry: HistoryEntry): number =>\n estimateTokens(Option.getOrElse(jsonOf(entry), () => \"\")) + ONE;\n\nexport interface Fitting {\n readonly history: readonly Option.Option<HistoryEntry>[];\n readonly perEntry: readonly number[];\n readonly tokens: number;\n}\n\nexport interface Plan {\n readonly messages: readonly Message[];\n readonly calls: readonly ToolCall[];\n readonly options: FitOptions;\n readonly stateOf: (history: readonly HistoryEntry[]) => CompactionState;\n readonly baseTokens: number;\n readonly byMessage: ReadonlyMap<number, readonly ToolCall[]>;\n}\n\nexport type Change = (entry: HistoryEntry) => Option.Option<Option.Option<HistoryEntry>>;\n\nexport const fittingOf = (plan: Plan, history: readonly HistoryEntry[]): Fitting => {\n const perEntry = pipe(history, Arr.map(entryTokens));\n return {\n history: pipe(history, Arr.map(Option.some)),\n perEntry,\n tokens: plan.baseTokens + Num.sumAll(perEntry),\n };\n};\n\nexport const kept = (fitting: Fitting): readonly HistoryEntry[] => Arr.getSomes(fitting.history);\n\nexport const fits = (plan: Plan, fitting: Fitting): boolean =>\n fitting.tokens <= plan.options.maxStateTokens;\n\nexport const fitted = (plan: Plan, fitting: Fitting, stage: string): FittedState => ({\n state: plan.stateOf(kept(fitting)),\n tokens: fitting.tokens,\n stage,\n});\n\nexport const pinnedEntry = (plan: Plan, entry: HistoryEntry): boolean =>\n isPinned(entry.index, plan.messages.length, plan.options.preserveRecentMessages);\n\nconst orderOf = (plan: Plan, fitting: Fitting): readonly number[] => {\n const present = pipe(\n fitting.history,\n Arr.flatMap((entry, index) =>\n pipe(\n entry,\n Option.map((value) => [index, pinnedEntry(plan, value)] as const),\n Option.toArray,\n ),\n ),\n );\n const loose = pipe(\n present,\n Arr.filter(([, pinned]) => !pinned),\n );\n const pinned = pipe(\n present,\n Arr.filter(([, isPinnedEntry]) => isPinnedEntry),\n );\n return pipe(\n [...loose, ...pinned],\n Arr.map(([index]) => index),\n );\n};\n\ninterface Step {\n readonly index: number;\n readonly entry: Option.Option<HistoryEntry>;\n readonly tokens: number;\n}\n\nconst stepOf =\n (fitting: Fitting, change: Change) =>\n (index: number): Option.Option<Step> =>\n pipe(\n Option.flatten(Option.fromUndefinedOr(fitting.history[index])),\n Option.flatMap(change),\n Option.map((entry) => ({\n index,\n entry,\n tokens: Option.match(entry, { onNone: () => NONE, onSome: entryTokens }),\n })),\n );\n\nconst applied = (fitting: Fitting, steps: readonly Step[]): Fitting => {\n const byIndex = new Map(\n pipe(\n steps,\n Arr.map((step) => [step.index, step] as const),\n ),\n );\n const pick = <Value>(index: number, value: Value, of: (step: Step) => Value): Value =>\n Option.match(Option.fromUndefinedOr(byIndex.get(index)), { onNone: () => value, onSome: of });\n const history = pipe(\n fitting.history,\n Arr.map((entry, index) => pick(index, entry, (step) => step.entry)),\n );\n const perEntry = pipe(\n fitting.perEntry,\n Arr.map((tokens, index) => pick(index, tokens, (step) => step.tokens)),\n );\n const delta = Num.sumAll(\n pipe(\n steps,\n Arr.map(\n (step) => step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n ),\n );\n return { history, perEntry, tokens: fitting.tokens + delta };\n};\n\nexport const staged = (\n plan: Plan,\n fitting: Fitting,\n change: Change,\n): readonly [Fitting, boolean] => {\n const steps = pipe(\n orderOf(plan, fitting),\n Arr.flatMap((index) => Option.toArray(stepOf(fitting, change)(index))),\n );\n const totals = pipe(\n steps,\n Arr.scan(\n fitting.tokens,\n (tokens, step) =>\n tokens + step.tokens - Option.getOrElse(Arr.get(fitting.perEntry, step.index), () => NONE),\n ),\n Arr.drop(ONE),\n );\n return Option.match(\n Arr.findFirstIndex(totals, (tokens) => tokens <= plan.options.maxStateTokens),\n {\n onNone: () => [applied(fitting, steps), false] as const,\n onSome: (at) => [applied(fitting, Arr.take(steps, at + ONE)), true] as const,\n },\n );\n};\n","import {\n Array as Arr,\n Effect,\n Option,\n Predicate,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { estimateTokens } from \"#/shared/lib/tokens.ts\";\n\nimport { callsByMessage, compactCall, historyEntries, jsonOf, truncate } from \"./calls.ts\";\nimport { fits, fitted, fittingOf, kept, pinnedEntry, staged } from \"./fitting.ts\";\nimport type { Change, Fitting, Plan } from \"./fitting.ts\";\nimport type {\n CompactionState,\n FitOptions,\n FittedState,\n HistoryEntry,\n HistoryToolCall,\n Message,\n ToolCall,\n} from \"./types.ts\";\n\nexport const STATE_CONTEXT =\n \"A coding assistant conversation is being compacted to free context. `history` is the whole conversation so far, oldest first; tool outputs are replaced by a short `result` note and long texts may be abridged. Each question asks whether one tool call, or the full output of that call, still needs to stay in the history verbatim. Whatever is not kept is deleted permanently, but the assistant can always re-run a tool or re-read a file.\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class HistoryTooLarge extends taggedError<\n HistoryTooLarge,\n { readonly brand: unique symbol }\n>()(\"HistoryTooLarge\", { reason: Schema.String }) {}\n\nconst FULL_INPUT_CHARS = 1000;\nconst SHORT_INPUT_CHARS = 200;\nconst SHORTEST_INPUT_CHARS = 60;\nconst SHORTER_INPUT_CHARS = [SHORT_INPUT_CHARS, SHORTEST_INPUT_CHARS] as const;\nconst TEXT_HEAD = 400;\nconst TEXT_TAIL = 150;\nconst ABRIDGE_MARGIN = 40;\nconst RECENT_GOALS = 3;\nconst GOAL_CHARS = 500;\nconst ONE = 1;\n\nconst abridge = (text: string): string => {\n const omitted = Str.length(text) - TEXT_HEAD - TEXT_TAIL;\n return `${Str.takeLeft(TEXT_HEAD)(text)}\\n[… ${String(omitted)} chars omitted …]\\n${Str.takeRight(TEXT_TAIL)(text)}`;\n};\n\nexport const goalFromMessages = (messages: readonly Message[]): string =>\n pipe(\n messages,\n Arr.filter(\n (message) =>\n message.role === \"user\" &&\n Str.isNonEmpty(Str.trim(message.text)) &&\n Arr.isReadonlyArrayEmpty(message.toolResults),\n ),\n Arr.takeRight(RECENT_GOALS),\n Arr.map((message) => truncate(message.text, GOAL_CHARS)),\n Arr.join(\"\\n\"),\n );\n\nconst abridgeText: Change = (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.some({ ...entry, text: abridge(entry.text) }),\n () => Str.length(entry.text) > TEXT_HEAD + TEXT_TAIL + ABRIDGE_MARGIN,\n );\n\nconst collapseText =\n (plan: Plan): Change =>\n (entry: HistoryEntry) => {\n const original = pipe(\n Arr.get(plan.messages, entry.index),\n Option.map((message) => Str.length(message.text)),\n Option.getOrElse(() => Str.length(entry.text)),\n );\n return Option.liftPredicate(\n Option.some({ ...entry, text: `[… ${String(original)} chars omitted …]` }),\n () => !pinnedEntry(plan, entry) && Str.isNonEmpty(entry.text),\n );\n };\n\nconst compactCalls =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n pipe(\n Option.fromUndefinedOr(plan.byMessage.get(entry.index)),\n Option.filter(() => !pinnedEntry(plan, entry)),\n Option.map((own) => Option.some({ ...entry, tool_calls: pipe(own, Arr.map(compactCall)) })),\n );\n\nconst leaveOut =\n (plan: Plan): Change =>\n (entry: HistoryEntry) =>\n Option.liftPredicate(\n Option.none<HistoryEntry>(),\n () => !pinnedEntry(plan, entry) && Predicate.isUndefined(entry.tool_calls),\n );\n\nconst callsOf = (entry: HistoryEntry): readonly (HistoryToolCall | string)[] =>\n Option.getOrElse(Option.fromUndefinedOr(entry.tool_calls), () => []);\n\nconst stringCalls = (entry: HistoryEntry): readonly string[] =>\n pipe(callsOf(entry), Arr.filter(Predicate.isString));\n\nconst foldable = (plan: Plan, entry: HistoryEntry): boolean =>\n !pinnedEntry(plan, entry) &&\n Str.isEmpty(entry.text) &&\n pipe(Arr.head(callsOf(entry)), Option.exists(Predicate.isString));\n\nconst mergedRun = (group: Arr.NonEmptyReadonlyArray<HistoryEntry>): HistoryEntry => {\n const first = Arr.headNonEmpty(group);\n if (group.length === ONE) {\n return first;\n }\n return { ...first, tool_calls: pipe(group, Arr.flatMap(stringCalls)) };\n};\n\nconst mergeRuns = (plan: Plan, history: readonly HistoryEntry[]): readonly HistoryEntry[] => {\n if (!Arr.isReadonlyArrayNonEmpty(history)) {\n return [];\n }\n return pipe(\n Arr.groupWith(\n history,\n (left, right) => foldable(plan, left) && foldable(plan, right) && left.role === right.role,\n ),\n Arr.map(mergedRun),\n );\n};\n\ntype Stage = readonly [string, (fitting: Fitting) => readonly [Fitting, boolean]];\n\nconst rebuilt = (plan: Plan, inputChars: number) => (): readonly [Fitting, boolean] => {\n const fitting = fittingOf(plan, historyEntries(plan.messages, plan.calls, inputChars));\n return [fitting, fits(plan, fitting)];\n};\n\nconst stagesOf = (plan: Plan): readonly Stage[] => [\n ...pipe(\n SHORTER_INPUT_CHARS,\n Arr.map((limit): Stage => [`inputs<=${String(limit)}`, rebuilt(plan, limit)]),\n ),\n [\"texts abridged\", (fitting) => staged(plan, fitting, abridgeText)],\n [\"old messages collapsed\", (fitting) => staged(plan, fitting, collapseText(plan))],\n [\"old calls compacted\", (fitting) => staged(plan, fitting, compactCalls(plan))],\n [\"old messages left out\", (fitting) => staged(plan, fitting, leaveOut(plan))],\n [\n \"old calls merged\",\n (fitting) => {\n const merged = fittingOf(plan, mergeRuns(plan, kept(fitting)));\n return [merged, fits(plan, merged)];\n },\n ],\n];\n\nconst throughStages = (\n plan: Plan,\n fitting: Fitting,\n stages: readonly Stage[],\n): Result.Result<FittedState, Fitting> =>\n Option.match(Arr.head(stages), {\n onNone: () => Result.fail(fitting),\n onSome: ([name, run]) => {\n const [next, done] = run(fitting);\n if (done) {\n return Result.succeed(fitted(plan, next, name));\n }\n return throughStages(plan, next, Arr.drop(stages, ONE));\n },\n });\n\nconst jsonText = (value: unknown): string => Option.getOrElse(jsonOf(value), () => \"\");\n\nconst planOf = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Plan => {\n const goal = pipe(\n Option.liftPredicate(options.goal, Str.isNonEmpty),\n Option.getOrElse(() => goalFromMessages(messages)),\n );\n const stateOf = (history: readonly HistoryEntry[]): CompactionState => ({\n context: STATE_CONTEXT,\n goal,\n history,\n });\n return {\n messages,\n calls,\n options,\n stateOf,\n baseTokens: estimateTokens(jsonText(stateOf([]))),\n byMessage: callsByMessage(calls),\n };\n};\n\nexport const fitState = (\n messages: readonly Message[],\n calls: readonly ToolCall[],\n options: FitOptions,\n): Effect.Effect<FittedState, HistoryTooLarge> => {\n const plan = planOf(messages, calls, options);\n const full = fittingOf(plan, historyEntries(messages, calls, FULL_INPUT_CHARS));\n if (fits(plan, full)) {\n return Effect.succeed(fitted(plan, full, \"full\"));\n }\n return Result.match(throughStages(plan, full, stagesOf(plan)), {\n onSuccess: Effect.succeed,\n onFailure: (last) =>\n Effect.fail(\n HistoryTooLarge.make({\n reason: `history too large for Jev (~${String(last.tokens)} tokens after truncation, limit ${String(options.maxStateTokens)})`,\n }),\n ),\n });\n};\n","import { Array as Arr, Effect, FileSystem, Path, Record as Rec, Schema, pipe } from \"effect\";\n\nconst InstalledEntry = Schema.Struct({\n installPath: Schema.String,\n version: Schema.Unknown,\n gitCommitSha: Schema.Unknown,\n});\nconst InstalledPlugins = Schema.Struct({\n plugins: Schema.Record(Schema.String, Schema.Array(InstalledEntry)),\n});\nconst decodeInstalled = Schema.decodeUnknownEffect(Schema.fromJsonString(InstalledPlugins));\n\nexport interface InstalledPlugin {\n readonly id: string;\n readonly installPath: string;\n readonly version: unknown;\n readonly sha: unknown;\n}\n\nconst flattened = (installed: typeof InstalledPlugins.Type): readonly InstalledPlugin[] =>\n pipe(\n Rec.toEntries(installed.plugins),\n Arr.flatMap(([id, entries]) =>\n pipe(\n entries,\n Arr.map((entry) => ({\n id,\n installPath: entry.installPath,\n version: entry.version,\n sha: entry.gitCommitSha,\n })),\n ),\n ),\n );\n\n/** @internal */\nexport const installedPlugins = Effect.fn(\"installedPlugins\")(function* installedPlugins(\n home: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(home, \".claude\", \"plugins\", \"installed_plugins.json\");\n return yield* fs.readFileString(file).pipe(\n Effect.flatMap(decodeInstalled),\n Effect.map(flattened),\n Effect.orElseSucceed((): readonly InstalledPlugin[] => []),\n );\n});\n","import {\n Array as Arr,\n Option,\n Predicate,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nexport type Place = \"ci\" | \"cloud\" | \"local\";\n\nexport interface Origin {\n readonly place: Place;\n readonly project: string;\n readonly hook: string;\n readonly sessionId: string;\n}\n\nexport interface JevSettings {\n readonly openRouterKey: string;\n readonly openRouterModel: string;\n readonly allowTraining: boolean;\n readonly attribution: Readonly<Record<string, string>>;\n}\n\nexport interface JevBackend {\n readonly apiKey: string;\n readonly baseURL: string;\n readonly model: string;\n readonly extra: Readonly<Record<string, unknown>>;\n readonly headers: Readonly<Record<string, string>>;\n readonly textState: boolean;\n}\n\nexport interface PlaceEnv {\n readonly githubActions: string;\n readonly remote: string;\n}\n\nexport type JevState = Readonly<Record<string, string>>;\n\nconst DEFAULT_OPENROUTER_MODEL = \"respan/span-01-lite\";\nconst TEXT_STATE_PREFIX = \"respan/\";\nconst encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\nexport const placeOf = (env: PlaceEnv): Place => {\n if (env.githubActions === \"true\") {\n return \"ci\";\n }\n if (env.remote === \"true\") {\n return \"cloud\";\n }\n return \"local\";\n};\n\nconst dataCollection = (allowTraining: boolean): string => {\n if (allowTraining) {\n return \"allow\";\n }\n return \"deny\";\n};\n\nexport const jevBackend = (settings: JevSettings, origin: Origin): JevBackend => {\n const model = pipe(\n Option.liftPredicate(settings.openRouterModel, Str.isNonEmpty),\n Option.getOrElse(() => DEFAULT_OPENROUTER_MODEL),\n );\n const session = pipe(\n Option.liftPredicate(origin.sessionId, Str.isNonEmpty),\n Option.match({ onNone: () => ({}), onSome: (id) => ({ session_id: id }) }),\n );\n return {\n apiKey: settings.openRouterKey,\n baseURL: \"https://openrouter.ai/api\",\n model,\n extra: {\n provider: { data_collection: dataCollection(settings.allowTraining) },\n user: `${origin.place}:${origin.project}:${origin.hook}`,\n ...session,\n },\n headers: settings.attribution,\n textState: Str.startsWith(TEXT_STATE_PREFIX)(model),\n };\n};\n\nconst sectionOf = ([key, value]: readonly [string, unknown]): string => {\n const text = pipe(\n Option.liftPredicate(value, Predicate.isString),\n Option.orElse(() => encodeJson(value)),\n Option.getOrElse(() => \"\"),\n );\n return `## ${key}\\n${text}`;\n};\n\nexport const stateFor = (backend: JevBackend, state: JevState): JevState | string => {\n if (!backend.textState) {\n return state;\n }\n return pipe(Rec.toEntries(state), Arr.map(sectionOf), Arr.join(\"\\n\\n\"));\n};\n"],"mappings":";;;;AAEA,MAAMA,gBAAc,OAAO;AAE3B,IAAa,iBAAb,cAAoCA,cAGlC,CAAC,CAAC,kBAAkB,EAAE,SAAS,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,MAAM,YAAY;AAClB,MAAa,uBAAuB;AAEpC,MAAM,YAAY,SAChB,OAAO,OAAO,OAAO,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,cAAc,OAAO,IAAI,CAAC;AAEnF,MAAM,gBAAsD,OAAO,IAAI,UAAU,gBAAgB;CAC/F,MAAM,YAAY,OAAO,SAAS,gBAAgB;CAClD,MAAM,OAAO,OAAO,SAAS,MAAM;CACnC,MAAM,UAAU,OAAO,SAAS,aAAa;CAC7C,OAAO,KACL,WACA,OAAO,aACL,KACE,OAAO,OAAO,YAAY,OAAO,GACjC,OAAO,KAAK,cAAc,GAAG,YAAY,YAAY,sBAAsB,CAC7E,CACF,CACF;AACF,CAAC;AAED,MAAa,mBACX,aAEA,cAAc,KACZ,OAAO,QACL,OAAO,MAAM;CACX,cAAc,OAAO,KAAK,eAAe,KAAK,EAAE,SAAS,6BAA6B,CAAC,CAAC;CACxF,SAAS,SAAS,OAAO,QAAQ,KAAK,CAAC,MAAM,GAAG,QAAQ,GAAGC,MAAI,KAAK,SAAS,CAAC,CAAC;AACjF,CAAC,CACH,CACF;AAEF,MAAa,eAAe,aAC1B,OAAO,WAAW,gBAAgB,QAAQ,CAAC;;ACjC7C,MAAa,WAAW,GAAGC,SAAaC,UAAc,OAAO,CAAC;AAE9D,MAAa,aAAa,SACxB,aAAa,eAAe,OAAO,CAAC,CAAC,CAAC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AAS,QAAQ,EAAE,YAAY,GAAG;CAAG,CAAC,CAC3E;CACA,OAAO;EACL,QAAQ,SAAS;EACjB,SAAS;EACT;EACA,OAAO;GACL,UAAU,EAAE,iBAAiB,eAAe,SAAS,aAAa,EAAE;GACpE,MAAM,GAAG,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG,OAAO;GAClD,GAAG;EACL;EACA,SAAS,SAAS;EAClB,WAAWA,SAAI,WAAW,iBAAiB,CAAC,CAAC,KAAK;CACpD;AACF;AAEA,MAAM,aAAa,CAAC,KAAK,WAA+C;CAMtE,OAAO,MAAM,IAAI,IALJ,KACX,OAAO,cAAc,OAAO,UAAU,QAAQ,GAC9C,OAAO,aAAa,WAAW,KAAK,CAAC,GACrC,OAAO,gBAAgB,EAAE,CAEH;AAC1B;AAEA,MAAa,YAAY,SAAqB,UAAuC;CACnF,IAAI,CAAC,QAAQ,WACX,OAAO;CAET,OAAO,KAAKC,OAAI,UAAU,KAAK,GAAGC,MAAI,IAAI,SAAS,GAAGA,MAAI,KAAK,MAAM,CAAC;AACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/masseater-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "The small shared libraries of masseater's repositories as subpaths of one package: a chip row for React, Claude Code plugin helpers, Effect entry points for Node.js and GitHub Actions, file import mapping, Node package readers, OTLP assertions for Vitest and Cloudflare Workers tracing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"actions",
|