@effected/yaml 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  Zero-dependency YAML 1.2 parsing, editing, formatting and linting expressed as Effect schemas and pure functions. Parse a single document or a multi-document stream into plain values or an offset-preserving AST, resolve anchors and aliases, read and preserve per-node comments, strip comments, compute byte-minimal edits, format, modify by path, walk a document as a `Stream` of AST events or positioned tokens, lint it against a rule catalog with surgical autofix — inferring the lint config from files you already have — and decode straight into a validated domain schema.
9
9
 
10
- > **Pre-release.** This package is part of the `@effected/*` kit, in pre-`1.0.0`
11
- > development against a single pinned Effect v4 prerelease. Packages graduate to
12
- > `1.0.0` once Effect `4.0.0` ships. To hold your own `effect` versions at
13
- > exactly the ones the kit is built and tested against, install
10
+ > **Pre-`1.0.0`.** This package is part of the `@effected/*` kit, built on stable
11
+ > Effect v4 (`effect` `^4.0.0`) and still in `0.x` development. Stable Effect
12
+ > makes a kit `1.0.0` possible, not automatic. To keep your `effect` and
13
+ > `@effect/*` versions on the line the kit is built and tested against, install
14
14
  > [`@effected/pnpm-plugin-effect`](https://www.npmjs.com/package/@effected/pnpm-plugin-effect).
15
15
  >
16
16
  > **Stability: unstable.** This package's API surface is not yet considered
package/Yaml.js CHANGED
@@ -40,8 +40,7 @@ var YamlParseOptions = class extends Schema.Class("YamlParseOptions")({
40
40
  * `false`.
41
41
  *
42
42
  * `lineWidth` controls column-based scalar folding. The default `0` (and any
43
- * value `<= 0`) never wraps, emitting byte-identical output to the historic
44
- * no-fold behavior; a positive value folds long plain, double-quoted and
43
+ * value `<= 0`) never wraps; a positive value folds long plain, double-quoted and
45
44
  * block-folded (`>`) scalars at approximately that column, inserting only
46
45
  * semantically transparent line breaks. Block-literal (`|`) content is never
47
46
  * folded — literal blocks preserve their bytes by definition. Folding is a
@@ -49,15 +48,14 @@ var YamlParseOptions = class extends Schema.Class("YamlParseOptions")({
49
48
  * helpers accept these options but do not fold (see `lineWidth`).
50
49
  *
51
50
  * `indentSequences` controls the presentation of block sequences nested under
52
- * a mapping key: `false` (the default) emits them at the key's column — the
53
- * kit's byte-compatible legacy form — while `true` indents them one level,
51
+ * a mapping key: `false` (the default) emits them at the key's column, while
52
+ * `true` indents them one level,
54
53
  * matching the `yaml` npm package's default output. Top-level sequences stay
55
54
  * at column zero in both modes.
56
55
  *
57
56
  * `quoteStyle` selects the quote character used when a `plain`-styled scalar
58
57
  * (the `defaultScalarStyle` default) turns out to require quoting: `"single"`
59
- * (the default) emits `'@parcel/watcher'` — the kit's byte-compatible legacy
60
- * form — while `"double"` emits `"@parcel/watcher"`, matching the `yaml` npm
58
+ * (the default) emits `'@parcel/watcher'`, while `"double"` emits `"@parcel/watcher"`, matching the `yaml` npm
61
59
  * package's `singleQuote: false` output. It is a fallback selector only:
62
60
  * scalars that need no quoting stay plain, and an explicit
63
61
  * `defaultScalarStyle` of `"single-quoted"` or `"double-quoted"` still wins.
@@ -106,7 +104,7 @@ var YamlStringifyOptions = class extends Schema.Class("YamlStringifyOptions")({
106
104
  indentSequences: Schema.optionalKey(Schema.Boolean),
107
105
  /**
108
106
  * Quote style used when a `plain`-styled scalar requires quoting. Default
109
- * `"single"` — the released byte-compatible behavior. `"double"` renders
107
+ * `"single"`. `"double"` renders
110
108
  * the same scalars double-quoted instead, matching the `yaml` npm
111
109
  * package's `singleQuote: false` output.
112
110
  *
@@ -118,7 +116,7 @@ var YamlStringifyOptions = class extends Schema.Class("YamlStringifyOptions")({
118
116
  /**
119
117
  * Additionally quote plain scalars a foreign resolution dialect would
120
118
  * coerce to a non-string. Absent (the default) adds no quoting beyond the
121
- * YAML 1.2 Core Schema rules — byte-identical to the released output.
119
+ * YAML 1.2 Core Schema rules.
122
120
  *
123
121
  * `"yaml-1.1"` quotes every plain scalar a YAML 1.1 parser (js-yaml,
124
122
  * PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema, whose
@@ -315,7 +313,7 @@ const stringifyResultImpl = (value, options) => {
315
313
  /**
316
314
  * Collect the raw diagnostics that make a composed document a parse failure:
317
315
  * every fatal-code error, plus DuplicateKey warnings promoted to errors when
318
- * `uniqueKeys` is in force (the v3 `parse` contract). Order preserved:
316
+ * `uniqueKeys` is in force. Order preserved:
319
317
  * fatals first, then promotions.
320
318
  */
321
319
  const failureRecords = (doc, uniqueKeys) => {
@@ -370,6 +368,12 @@ var Yaml = class Yaml {
370
368
  *
371
369
  * Defined in terms of {@link Yaml.parseResult} — synchronous callers can
372
370
  * use that variant directly.
371
+ *
372
+ * @param text - The YAML source to parse.
373
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
374
+ * omitted fields.
375
+ * @returns An `Effect` that succeeds with the decoded value, or fails with
376
+ * the aggregate {@link YamlParseError}.
373
377
  */
374
378
  static parse = Effect.fn("Yaml.parse")((text, options) => Effect.fromResult(Yaml.parseResult(text, options)));
375
379
  /**
@@ -384,6 +388,12 @@ var Yaml = class Yaml {
384
388
  *
385
389
  * Defined in terms of {@link Yaml.parseAllResult} — synchronous callers
386
390
  * can use that variant directly.
391
+ *
392
+ * @param text - The YAML stream to parse.
393
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
394
+ * omitted fields.
395
+ * @returns An `Effect` that succeeds with one value per document, or fails
396
+ * with the aggregate {@link YamlParseError}.
387
397
  */
388
398
  static parseAll = Effect.fn("Yaml.parseAll")((text, options) => Effect.fromResult(Yaml.parseAllResult(text, options)));
389
399
  /**
@@ -401,6 +411,12 @@ var Yaml = class Yaml {
401
411
  * `"<<"` key on a plain JavaScript object is an ordinary string key that
402
412
  * never carried merge semantics, so emitting it plain would silently turn
403
413
  * ordinary data into a merge directive.
414
+ *
415
+ * @param value - The plain JavaScript value to stringify.
416
+ * @param options - Optional {@link YamlStringifyOptions}; defaults apply for
417
+ * omitted fields.
418
+ * @returns An `Effect` that succeeds with the YAML text, or fails with
419
+ * {@link YamlStringifyError}.
404
420
  */
405
421
  static stringify = Effect.fn("Yaml.stringify")(function* (value, options) {
406
422
  return yield* stringifyOrFail(value, options);
@@ -516,6 +532,11 @@ var Yaml = class Yaml {
516
532
  * `replaceCh` (e.g. `" "`), each comment character is replaced instead,
517
533
  * keeping all offsets stable. Quote-aware: `#` inside quoted scalars is
518
534
  * content, not a comment. Pure and total.
535
+ *
536
+ * @param text - The YAML source to strip.
537
+ * @param replaceCh - Optional single character replacing each stripped
538
+ * comment character (offset-preserving).
539
+ * @returns The text without comments.
519
540
  */
520
541
  static stripComments(text, replaceCh) {
521
542
  let result = "";
@@ -565,6 +586,10 @@ var Yaml = class Yaml {
565
586
  * significant. Malformed input is never equal to anything — parse errors
566
587
  * (or duplicate keys) on either side yield `false` rather than comparing
567
588
  * recovery-parser artifacts. Pure and total.
589
+ *
590
+ * @param a - The first YAML source.
591
+ * @param b - The second YAML source.
592
+ * @returns `true` when `a` and `b` decode to structurally equal values.
568
593
  */
569
594
  static equals(a, b) {
570
595
  const va = parseForEquality(a);
@@ -576,6 +601,11 @@ var Yaml = class Yaml {
576
601
  * Compare a YAML string against an existing JavaScript value with the
577
602
  * same semantics as {@link Yaml.equals}: malformed `text` yields `false`.
578
603
  * Pure and total.
604
+ *
605
+ * @param text - The YAML source to decode and compare.
606
+ * @param value - The plain JavaScript value to compare against.
607
+ * @returns `true` when `text` decodes to a value structurally equal to
608
+ * `value`.
579
609
  */
580
610
  static equalsValue(text, value) {
581
611
  const v = parseForEquality(text);
@@ -628,11 +658,14 @@ var Yaml = class Yaml {
628
658
  /**
629
659
  * Compose {@link Yaml.fromString} with a target schema, yielding a
630
660
  * `Schema<A, string>` that decodes YAML straight into a validated domain
631
- * value — the single best consumer-facing feature of the library. The
632
- * target's decoding/encoding service requirements flow through.
661
+ * value. The target's decoding/encoding service requirements flow through.
633
662
  *
634
663
  * Schema-producing: bind the result to a `const` on hot paths (see
635
664
  * {@link Yaml.fromString}).
665
+ *
666
+ * @param target - The domain schema decoded values must satisfy.
667
+ * @param options - Optional {@link YamlParseOptions} applied on decode.
668
+ * @returns A `Schema.Codec<T, string>` decoding YAML text straight into `T`.
636
669
  */
637
670
  static schema(target, options) {
638
671
  return Yaml.fromString(options).pipe(Schema.decodeTo(target));
package/YamlDiagnostic.js CHANGED
@@ -70,8 +70,10 @@ var YamlDiagnostic = class YamlDiagnostic extends Schema.Class("YamlDiagnostic")
70
70
  /**
71
71
  * The single fatal-code predicate: whether diagnostics with this code
72
72
  * abort a parse (vs. being recoverable warnings-as-data). Declared once,
73
- * as a property of the code — replacing the v3 source's three
74
- * subtly-differing inline fatal lists.
73
+ * as a property of the code.
74
+ *
75
+ * @param code - The diagnostic code to classify.
76
+ * @returns `true` when diagnostics with `code` abort a parse.
75
77
  */
76
78
  static isFatal(code) {
77
79
  return isFatalCode(code);
@@ -80,6 +82,10 @@ var YamlDiagnostic = class YamlDiagnostic extends Schema.Class("YamlDiagnostic")
80
82
  * Materialize a raw engine diagnostic record into a `YamlDiagnostic`,
81
83
  * deriving `line`/`character` from `offset` against the source `text`.
82
84
  * Advanced — the parse/stringify entry points call this for you.
85
+ *
86
+ * @param raw - The engine record: `code`, `message`, `offset` and `length`.
87
+ * @param text - The source text the record's `offset` indexes into.
88
+ * @returns The diagnostic with `line` and `character` filled in.
83
89
  */
84
90
  static fromRaw(raw, text) {
85
91
  const { line, character } = lineChar(text, raw.offset);
package/YamlDocument.js CHANGED
@@ -34,6 +34,17 @@ var YamlDirective = class extends Schema.Class("YamlDirective")({
34
34
  * Construct via `YamlDocument.parse` / `parseAll`; `YamlDocument.make` is for
35
35
  * synthetic documents.
36
36
  *
37
+ * @example
38
+ * ```ts
39
+ * import { YamlDocument } from "@effected/yaml";
40
+ * import { Effect } from "effect";
41
+ *
42
+ * const program = Effect.gen(function* () {
43
+ * const doc = yield* YamlDocument.parse("# header\nname: Alice\n");
44
+ * return doc.errors.length; // 0 — no recovered errors
45
+ * });
46
+ * ```
47
+ *
37
48
  * @public
38
49
  */
39
50
  var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
@@ -52,6 +63,12 @@ var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
52
63
  * recovered diagnostics. Fails with the aggregate {@link YamlParseError}
53
64
  * when any fatal-code diagnostic is present; non-fatal diagnostics are
54
65
  * data on the returned document.
66
+ *
67
+ * @param text - The YAML source to parse.
68
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
69
+ * omitted fields.
70
+ * @returns An `Effect` that succeeds with the {@link YamlDocument}, or fails
71
+ * with {@link YamlParseError}.
55
72
  */
56
73
  static parse = Effect.fn("YamlDocument.parse")(function* (text, options) {
57
74
  const raw = composeFirstDocument(text, toParseInput(options));
@@ -66,6 +83,12 @@ var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
66
83
  * Parse a multi-document YAML stream into one {@link YamlDocument} per
67
84
  * document. Any fatal diagnostic in any document — or a stream-level
68
85
  * directive-placement error — fails the whole Effect.
86
+ *
87
+ * @param text - The YAML stream to parse.
88
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
89
+ * omitted fields.
90
+ * @returns An `Effect` that succeeds with one {@link YamlDocument} per
91
+ * document, or fails with {@link YamlParseError}.
69
92
  */
70
93
  static parseAll = Effect.fn("YamlDocument.parseAll")(function* (text, options) {
71
94
  const { documents, streamErrors } = composeAllDocuments(text, toParseInput(options));
@@ -84,6 +107,9 @@ var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
84
107
  * Schema-producing: each call returns a fresh schema whose derivation
85
108
  * caches are not shared across calls; bind the result to a `const` on hot
86
109
  * paths.
110
+ *
111
+ * @param options - Optional {@link YamlParseOptions} applied on decode.
112
+ * @returns A `Schema.Codec<YamlDocument, string>`.
87
113
  */
88
114
  static schema(options) {
89
115
  return Schema.String.pipe(Schema.decodeTo(Schema.instanceOf(YamlDocument), SchemaTransformation.transformEffect({
@@ -109,6 +135,11 @@ var YamlDocument = class YamlDocument extends Schema.Class("YamlDocument")({
109
135
  * option. Callers that need folding should render the plain value
110
136
  * instead — `Yaml.stringify(doc.toValue(), options)` — at the cost of
111
137
  * the document-level framing and styles this path preserves.
138
+ *
139
+ * @param options - Optional {@link YamlStringifyOptions}; defaults apply for
140
+ * omitted fields.
141
+ * @returns An `Effect` that succeeds with the YAML text, or fails with
142
+ * {@link YamlStringifyError}.
112
143
  */
113
144
  stringify(options) {
114
145
  return Effect.try({
package/YamlEdit.js CHANGED
@@ -17,9 +17,10 @@ var YamlRange = class extends Schema.Class("YamlRange")({
17
17
  * `content`. Set `length` to `0` to insert, `content` to `""` to delete.
18
18
  *
19
19
  * @remarks
20
- * Structurally identical to `@effected/jsonc`'s edit shape (same field names,
21
- * types and semantics) per the jsonc/yaml parity convention, so consumer code
22
- * can be written once over "a document codec's Edit/Range/Path".
20
+ * Structurally identical to the edit shape of `@effected/jsonc`,
21
+ * `@effected/toml` and `@effected/markdown` (same field names, types and
22
+ * semantics), so consumer code can be written once over "a document codec's
23
+ * Edit/Range/Path".
23
24
  *
24
25
  * @public
25
26
  */
@@ -33,6 +34,10 @@ var YamlEdit = class extends Schema.Class("YamlEdit")({
33
34
  * reverse-offset order so earlier offsets stay valid; the input `edits`
34
35
  * array is not mutated. Overlapping edits are a programmer error and throw
35
36
  * as a defect — `YamlFormat` never produces them.
37
+ *
38
+ * @param text - The source text to edit.
39
+ * @param edits - The edits to apply, in any order.
40
+ * @returns The edited text.
36
41
  */
37
42
  static applyAll(text, edits) {
38
43
  const sorted = [...edits].sort((a, b) => b.offset - a.offset);
package/YamlFormat.js CHANGED
@@ -15,8 +15,8 @@ import { Effect, Schema } from "effect";
15
15
  * field (derived, not hand-duplicated — including `indentSequences`,
16
16
  * `quoteStyle` and `quoteCompat`) plus
17
17
  * `preserveComments` (default `true`), `range` (restrict edits to a
18
- * region; see the module-level remarks on the `range` parameter vs. this
19
- * field) and `requoteScalars` (default `false`).
18
+ * region; the positional `range` argument of {@link YamlFormat.format} takes
19
+ * precedence over this field) and `requoteScalars` (default `false`).
20
20
  *
21
21
  * `requoteScalars` makes `quoteStyle` apply to scalars **already quoted in
22
22
  * the source** on the format path — by default formatting preserves an
@@ -259,7 +259,7 @@ function formatStream(text, documents, streamErrors, options) {
259
259
  * Before this was recursive, a mapping or sequence value fell through to the
260
260
  * node stringifier's `String(value)` fallback and landed in the document as
261
261
  * the literal text `[object Object]` — a silent corruption that only surfaced
262
- * on the next read (#642).
262
+ * on the next read.
263
263
  *
264
264
  * The two conditions with no finite rendering fail typed rather than hanging
265
265
  * or overflowing the stack: a cycle raises `CircularReference` and a graph
@@ -472,7 +472,7 @@ function findExistingTarget(contents, path) {
472
472
  * resolved type — as does any plain target, so the stringifier's own
473
473
  * plain-safety rules decide whether the text needs quotes — under the
474
474
  * target's own context, so a flow indicator inside a value spliced into a
475
- * flow collection is quoted rather than corrupting the collection (#695). A
475
+ * flow collection is quoted rather than corrupting the collection. A
476
476
  * rendering that spans lines (folding, block styles) bails out: the fast
477
477
  * path never introduces a line break inside the spliced region.
478
478
  */
@@ -515,7 +515,7 @@ function regionalRenderPreservesValue(rendered, value, inFlow) {
515
515
  return Object.is(node.value, value);
516
516
  }
517
517
  /**
518
- * Attempt the region-confined scalar splice for `modify` (#659): replace
518
+ * Attempt the region-confined scalar splice for `modify`: replace
519
519
  * only the target scalar's byte range, re-emitting its original quote
520
520
  * character and leaving line endings (and every other byte) elsewhere
521
521
  * untouched. Returns the single edit, an empty array for a no-op
@@ -547,7 +547,22 @@ function tryRegionalScalarEdit(text, doc, path, value, options) {
547
547
  }];
548
548
  }
549
549
  /**
550
- * Formatting and modification statics. Not instantiable.
550
+ * Formats YAML text and modifies values at a path as byte-minimal edits that
551
+ * preserve comments and layout elsewhere. Not instantiable.
552
+ *
553
+ * @example
554
+ * ```ts
555
+ * import { YamlFormat } from "@effected/yaml";
556
+ * import { Effect } from "effect";
557
+ *
558
+ * const formatted = YamlFormat.formatToString("a: 1\nb:\n - x\n - y # c\n");
559
+ * // => "a: 1\nb:\n- x\n- y # c\n"
560
+ *
561
+ * const program = Effect.gen(function* () {
562
+ * return yield* YamlFormat.modifyToString("port: 3000 # dev\n", ["port"], 8080);
563
+ * // => "port: 8080 # dev\n"
564
+ * });
565
+ * ```
551
566
  *
552
567
  * @remarks
553
568
  * `format`/`formatToString` are pure and total (edit computation never fails
@@ -573,8 +588,8 @@ function tryRegionalScalarEdit(text, doc, path, value, options) {
573
588
  * (`!e!foo`) turns a valid file into one no parser can read. So
574
589
  * `format`/`formatToString` leave such input byte-identical (no edits), and
575
590
  * `modify`/`modifyToString` fail typed with a `DirectiveCarryingDocument`
576
- * diagnostic. Directive re-emission is unimplemented, not undesired — the
577
- * refusal is the floor that stops corruption until it lands.
591
+ * diagnostic. Directive re-emission is unimplemented, and the refusal is what
592
+ * stops the corruption.
578
593
  *
579
594
  * @public
580
595
  */
@@ -604,6 +619,12 @@ var YamlFormat = class YamlFormat {
604
619
  * directives is left untouched. Detection is directive-token-level: a
605
620
  * literal `%TAG` inside a scalar is content and formats normally.
606
621
  *
622
+ * @param text - The YAML source to format.
623
+ * @param range - Optional sub-range; only edits fully within it are returned.
624
+ * @param options - Optional {@link YamlFormattingOptions}.
625
+ * @returns The edits that bring `text` to canonical shape; apply them with
626
+ * `YamlEdit.applyAll`. Empty when the input cannot be formatted faithfully.
627
+ *
607
628
  * @remarks
608
629
  * The positional `range` argument takes precedence over
609
630
  * `options?.range` when both are given; either accepts a plain
@@ -646,6 +667,12 @@ var YamlFormat = class YamlFormat {
646
667
  * document — single or in a stream — carrying `%YAML`/`%TAG` directives)
647
668
  * is returned byte-identical — never a truncated first document, never a
648
669
  * document re-emitted without the directive its tags depend on.
670
+ *
671
+ * @param text - The YAML source to format.
672
+ * @param range - Optional sub-range; only edits fully within it are applied.
673
+ * @param options - Optional {@link YamlFormattingOptions}.
674
+ * @returns The formatted text, or `text` unchanged when it cannot be
675
+ * formatted faithfully.
649
676
  */
650
677
  static formatToString(text, range, options) {
651
678
  return YamlEdit.applyAll(text, YamlFormat.format(text, range, options));
@@ -661,15 +688,12 @@ var YamlFormat = class YamlFormat {
661
688
  * sequence and any other non-null object as a block mapping over its own
662
689
  * enumerable string keys, recursively — the same lowering
663
690
  * {@link Yaml.stringify} applies to the same value, so `modify` and
664
- * `stringify` agree on what a given JavaScript value means. (Before
665
- * 0.14.0 only scalars were lowered and a mapping or sequence value was
666
- * coerced through `String(value)`, writing the literal text
667
- * `[object Object]` into the document — see #642.) For a synthesized
691
+ * `stringify` agree on what a given JavaScript value means. For a synthesized
668
692
  * subtree (an object/array value) only the surrounding document is
669
693
  * preserved byte-for-byte; the subtree carries no comments and takes the
670
694
  * stringifier's styles.
671
695
  *
672
- * **Scalar replacement is region-confined and quote-preserving (#659).**
696
+ * **Scalar replacement is region-confined and quote-preserving.**
673
697
  * When the path resolves to an existing single-line `plain`,
674
698
  * `single-quoted`, or `double-quoted` scalar with no tag or anchor, and
675
699
  * the replacement is a string, number, or boolean, `modify` splices
@@ -710,6 +734,15 @@ var YamlFormat = class YamlFormat {
710
734
  * directive re-emission is unimplemented, not undesired. A literal
711
735
  * `%TAG` inside a scalar is content and does not trigger the refusal.
712
736
  *
737
+ * @param text - The YAML source to modify.
738
+ * @param path - The location to insert, replace or remove.
739
+ * @param value - The JavaScript value to write; `undefined` removes the
740
+ * target instead.
741
+ * @param options - Optional {@link YamlStringifyOptions} for the
742
+ * re-stringify step.
743
+ * @returns An `Effect` that succeeds with the edits to apply (via
744
+ * `YamlEdit.applyAll`), or fails with {@link YamlModificationError}.
745
+ *
713
746
  * @remarks
714
747
  * `options` is a bare {@link YamlStringifyOptions} — it controls only the
715
748
  * internal re-stringify step, not a range (there is no range to restrict
@@ -770,6 +803,15 @@ var YamlFormat = class YamlFormat {
770
803
  * error channel, including the single-document contract's
771
804
  * `MultiDocumentStream` refusal and the `DirectiveCarryingDocument`
772
805
  * refusal of `%YAML`/`%TAG`-carrying documents.
806
+ *
807
+ * @param text - The YAML source to modify.
808
+ * @param path - The location to insert, replace or remove.
809
+ * @param value - The JavaScript value to write; `undefined` removes the
810
+ * target instead.
811
+ * @param options - Optional {@link YamlStringifyOptions} for the
812
+ * re-stringify step.
813
+ * @returns An `Effect` that succeeds with the modified text, or fails with
814
+ * {@link YamlModificationError}.
773
815
  */
774
816
  static modifyToString = Effect.fn("YamlFormat.modifyToString")(function* (text, path, value, options) {
775
817
  const edits = yield* YamlFormat.modify(text, path, value, options);
package/YamlLint.js CHANGED
Binary file
package/YamlLintRule.js CHANGED
@@ -32,7 +32,7 @@ var YamlLintDiagnostic = class extends Schema.Class("YamlLintDiagnostic")({
32
32
  fix: Schema.optionalKey(YamlEdit)
33
33
  }) {};
34
34
  /**
35
- * One categorical style observation (#345): a single occurrence of a style
35
+ * One categorical style observation: a single occurrence of a style
36
36
  * choice in the source, voting a `value` for an inference `dimension`.
37
37
  *
38
38
  * The `dimension` IS the rule's option key and the `value` IS that option's
@@ -64,7 +64,7 @@ var StyleVote = class extends Schema.TaggedClass()("StyleVote", {
64
64
  character: Schema.Number
65
65
  }) {};
66
66
  /**
67
- * One measured style floor (#345): a value the source PROVES is at least
67
+ * One measured style floor: a value the source PROVES is at least
68
68
  * `value`, without proving what the configured limit should be — the longest
69
69
  * observed line proves `line-length.max` is at least that long, not what it
70
70
  * is. Floors are carried in the evidence for callers that want them and are
package/YamlToken.js CHANGED
@@ -82,7 +82,9 @@ const promoteAll = (text, tokens) => {
82
82
  });
83
83
  };
84
84
  /**
85
- * Tokenizer statics. Not instantiable.
85
+ * Tokenizes YAML text into positioned tokens, as a complete array or a lazy
86
+ * `Stream`, for lint- and editor-class consumers. Never fails on malformed
87
+ * input: lexical errors arrive as `"error"`-kind tokens. Not instantiable.
86
88
  *
87
89
  * @public
88
90
  */
@@ -91,12 +93,11 @@ var YamlTokens = class YamlTokens {
91
93
  /**
92
94
  * Tokenize YAML text into the full positioned token array — the sync
93
95
  * `Result` primitive (tokenizing is a pure batch transform; the
94
- * {@link YamlTokens.stream} form is derived from this one, per the kit's
95
- * sync-primitive policy).
96
+ * {@link YamlTokens.stream} form is derived from this one).
96
97
  *
97
98
  * @remarks
98
- * The failure channel is **reserved** (for future input-hardening guards)
99
- * and never fires today: the lexer is total, and lexical errors surface as
99
+ * The failure channel is **reserved** for input-hardening guards and never
100
+ * fires today: the lexer is total, and lexical errors surface as
100
101
  * `"error"`-kind tokens **in the success array** so that linting can run
101
102
  * on malformed input — the `parse-validity` lint rule exists precisely for
102
103
  * documents that do not parse. Do not "fix" this method to fail on
@@ -112,6 +113,9 @@ var YamlTokens = class YamlTokens {
112
113
  * result.success.map((t) => t.kind); // ["scalar", "block-map-start", ...]
113
114
  * }
114
115
  * ```
116
+ *
117
+ * @param text - The YAML source to tokenize.
118
+ * @returns A `Result` succeeding with every token in source order.
115
119
  */
116
120
  static tokenize(text) {
117
121
  return Result.succeed(promoteAll(text, lexAll(text)));
package/YamlVisitor.js CHANGED
@@ -13,7 +13,23 @@ import { Data, Stream } from "effect";
13
13
  */
14
14
  const YamlVisitorEvent = Data.taggedEnum();
15
15
  /**
16
- * SAX-style YAML AST visitor statics. Not instantiable.
16
+ * Walks YAML text as a lazy `Stream` of typed events — documents, collections,
17
+ * pairs, scalars, aliases, comments, directives and recovered errors — in
18
+ * document order. Not instantiable.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { YamlVisitor, YamlVisitorEvent } from "@effected/yaml";
23
+ * import { Effect, Stream } from "effect";
24
+ *
25
+ * // Mapping keys are scalar events too, so keys and values interleave.
26
+ * const scalars = YamlVisitor.visit("a: 1\nb:\n - x\n").pipe(
27
+ * Stream.filter(YamlVisitorEvent.$is("Scalar")),
28
+ * Stream.map((event) => event.value),
29
+ * Stream.runCollect,
30
+ * );
31
+ * // Effect.runSync(scalars) // => ["a", 1, "b", "x"]
32
+ * ```
17
33
  *
18
34
  * @public
19
35
  */
@@ -31,6 +47,11 @@ var YamlVisitor = class {
31
47
  * (fatal or not, including an exceeded `maxAliasCount`, recorded as
32
48
  * `AliasCountExceeded`) surface as `Error` events inside the stream rather
33
49
  * than failing it.
50
+ *
51
+ * @param text - The YAML source to visit.
52
+ * @param options - Optional {@link YamlParseOptions} controlling composition.
53
+ * @returns A lazy `Stream` of `YamlVisitorEvent`, infallible at the type
54
+ * level.
34
55
  */
35
56
  static visit(text, options) {
36
57
  return Stream.fromIterable(visitGen(text, options));
package/index.d.ts CHANGED
@@ -99,14 +99,20 @@ export declare class YamlDiagnostic extends YamlDiagnostic_base {
99
99
  /**
100
100
  * The single fatal-code predicate: whether diagnostics with this code
101
101
  * abort a parse (vs. being recoverable warnings-as-data). Declared once,
102
- * as a property of the code — replacing the v3 source's three
103
- * subtly-differing inline fatal lists.
102
+ * as a property of the code.
103
+ *
104
+ * @param code - The diagnostic code to classify.
105
+ * @returns `true` when diagnostics with `code` abort a parse.
104
106
  */
105
107
  static isFatal(code: YamlErrorCode): boolean;
106
108
  /**
107
109
  * Materialize a raw engine diagnostic record into a `YamlDiagnostic`,
108
110
  * deriving `line`/`character` from `offset` against the source `text`.
109
111
  * Advanced — the parse/stringify entry points call this for you.
112
+ *
113
+ * @param raw - The engine record: `code`, `message`, `offset` and `length`.
114
+ * @param text - The source text the record's `offset` indexes into.
115
+ * @returns The diagnostic with `line` and `character` filled in.
110
116
  */
111
117
  static fromRaw(raw: {
112
118
  readonly code: YamlErrorCode;
@@ -166,7 +172,7 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
166
172
  readonly indentSequences: Schema.optionalKey<Schema.Boolean>;
167
173
  /**
168
174
  * Quote style used when a `plain`-styled scalar requires quoting. Default
169
- * `"single"` — the released byte-compatible behavior. `"double"` renders
175
+ * `"single"`. `"double"` renders
170
176
  * the same scalars double-quoted instead, matching the `yaml` npm
171
177
  * package's `singleQuote: false` output.
172
178
  *
@@ -178,7 +184,7 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
178
184
  /**
179
185
  * Additionally quote plain scalars a foreign resolution dialect would
180
186
  * coerce to a non-string. Absent (the default) adds no quoting beyond the
181
- * YAML 1.2 Core Schema rules — byte-identical to the released output.
187
+ * YAML 1.2 Core Schema rules.
182
188
  *
183
189
  * `"yaml-1.1"` quotes every plain scalar a YAML 1.1 parser (js-yaml,
184
190
  * PyYAML, libyaml, and the `yaml` npm package's YAML 1.1 schema, whose
@@ -214,8 +220,7 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
214
220
  * `false`.
215
221
  *
216
222
  * `lineWidth` controls column-based scalar folding. The default `0` (and any
217
- * value `<= 0`) never wraps, emitting byte-identical output to the historic
218
- * no-fold behavior; a positive value folds long plain, double-quoted and
223
+ * value `<= 0`) never wraps; a positive value folds long plain, double-quoted and
219
224
  * block-folded (`>`) scalars at approximately that column, inserting only
220
225
  * semantically transparent line breaks. Block-literal (`|`) content is never
221
226
  * folded — literal blocks preserve their bytes by definition. Folding is a
@@ -223,15 +228,14 @@ declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Sche
223
228
  * helpers accept these options but do not fold (see `lineWidth`).
224
229
  *
225
230
  * `indentSequences` controls the presentation of block sequences nested under
226
- * a mapping key: `false` (the default) emits them at the key's column — the
227
- * kit's byte-compatible legacy form — while `true` indents them one level,
231
+ * a mapping key: `false` (the default) emits them at the key's column, while
232
+ * `true` indents them one level,
228
233
  * matching the `yaml` npm package's default output. Top-level sequences stay
229
234
  * at column zero in both modes.
230
235
  *
231
236
  * `quoteStyle` selects the quote character used when a `plain`-styled scalar
232
237
  * (the `defaultScalarStyle` default) turns out to require quoting: `"single"`
233
- * (the default) emits `'@parcel/watcher'` — the kit's byte-compatible legacy
234
- * form — while `"double"` emits `"@parcel/watcher"`, matching the `yaml` npm
238
+ * (the default) emits `'@parcel/watcher'`, while `"double"` emits `"@parcel/watcher"`, matching the `yaml` npm
235
239
  * package's `singleQuote: false` output. It is a fallback selector only:
236
240
  * scalars that need no quoting stay plain, and an explicit
237
241
  * `defaultScalarStyle` of `"single-quoted"` or `"double-quoted"` still wins.
@@ -346,6 +350,12 @@ export declare class Yaml {
346
350
  *
347
351
  * Defined in terms of {@link Yaml.parseResult} — synchronous callers can
348
352
  * use that variant directly.
353
+ *
354
+ * @param text - The YAML source to parse.
355
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
356
+ * omitted fields.
357
+ * @returns An `Effect` that succeeds with the decoded value, or fails with
358
+ * the aggregate {@link YamlParseError}.
349
359
  */
350
360
  static readonly parse: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<unknown, YamlParseError, never>;
351
361
  /**
@@ -360,6 +370,12 @@ export declare class Yaml {
360
370
  *
361
371
  * Defined in terms of {@link Yaml.parseAllResult} — synchronous callers
362
372
  * can use that variant directly.
373
+ *
374
+ * @param text - The YAML stream to parse.
375
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
376
+ * omitted fields.
377
+ * @returns An `Effect` that succeeds with one value per document, or fails
378
+ * with the aggregate {@link YamlParseError}.
363
379
  */
364
380
  static readonly parseAll: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<readonly unknown[], YamlParseError, never>;
365
381
  /**
@@ -377,6 +393,12 @@ export declare class Yaml {
377
393
  * `"<<"` key on a plain JavaScript object is an ordinary string key that
378
394
  * never carried merge semantics, so emitting it plain would silently turn
379
395
  * ordinary data into a merge directive.
396
+ *
397
+ * @param value - The plain JavaScript value to stringify.
398
+ * @param options - Optional {@link YamlStringifyOptions}; defaults apply for
399
+ * omitted fields.
400
+ * @returns An `Effect` that succeeds with the YAML text, or fails with
401
+ * {@link YamlStringifyError}.
380
402
  */
381
403
  static readonly stringify: (value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlStringifyError, never>;
382
404
  /**
@@ -484,6 +506,11 @@ export declare class Yaml {
484
506
  * `replaceCh` (e.g. `" "`), each comment character is replaced instead,
485
507
  * keeping all offsets stable. Quote-aware: `#` inside quoted scalars is
486
508
  * content, not a comment. Pure and total.
509
+ *
510
+ * @param text - The YAML source to strip.
511
+ * @param replaceCh - Optional single character replacing each stripped
512
+ * comment character (offset-preserving).
513
+ * @returns The text without comments.
487
514
  */
488
515
  static stripComments(text: string, replaceCh?: string): string;
489
516
  /**
@@ -492,12 +519,21 @@ export declare class Yaml {
492
519
  * significant. Malformed input is never equal to anything — parse errors
493
520
  * (or duplicate keys) on either side yield `false` rather than comparing
494
521
  * recovery-parser artifacts. Pure and total.
522
+ *
523
+ * @param a - The first YAML source.
524
+ * @param b - The second YAML source.
525
+ * @returns `true` when `a` and `b` decode to structurally equal values.
495
526
  */
496
527
  static equals(a: string, b: string): boolean;
497
528
  /**
498
529
  * Compare a YAML string against an existing JavaScript value with the
499
530
  * same semantics as {@link Yaml.equals}: malformed `text` yields `false`.
500
531
  * Pure and total.
532
+ *
533
+ * @param text - The YAML source to decode and compare.
534
+ * @param value - The plain JavaScript value to compare against.
535
+ * @returns `true` when `text` decodes to a value structurally equal to
536
+ * `value`.
501
537
  */
502
538
  static equalsValue(text: string, value: unknown): boolean;
503
539
  /**
@@ -528,11 +564,14 @@ export declare class Yaml {
528
564
  /**
529
565
  * Compose {@link Yaml.fromString} with a target schema, yielding a
530
566
  * `Schema<A, string>` that decodes YAML straight into a validated domain
531
- * value — the single best consumer-facing feature of the library. The
532
- * target's decoding/encoding service requirements flow through.
567
+ * value. The target's decoding/encoding service requirements flow through.
533
568
  *
534
569
  * Schema-producing: bind the result to a `const` on hot paths (see
535
570
  * {@link Yaml.fromString}).
571
+ *
572
+ * @param target - The domain schema decoded values must satisfy.
573
+ * @param options - Optional {@link YamlParseOptions} applied on decode.
574
+ * @returns A `Schema.Codec<T, string>` decoding YAML text straight into `T`.
536
575
  */
537
576
  static schema<T, E, RD = never, RE = never>(target: Schema.Codec<T, E, RD, RE>, options?: YamlParseOptions): Schema.Codec<T, string, RD, RE>;
538
577
  /**
@@ -612,9 +651,10 @@ declare const YamlEdit_base: Schema.Class<YamlEdit, Schema.Struct<{
612
651
  * `content`. Set `length` to `0` to insert, `content` to `""` to delete.
613
652
  *
614
653
  * @remarks
615
- * Structurally identical to `@effected/jsonc`'s edit shape (same field names,
616
- * types and semantics) per the jsonc/yaml parity convention, so consumer code
617
- * can be written once over "a document codec's Edit/Range/Path".
654
+ * Structurally identical to the edit shape of `@effected/jsonc`,
655
+ * `@effected/toml` and `@effected/markdown` (same field names, types and
656
+ * semantics), so consumer code can be written once over "a document codec's
657
+ * Edit/Range/Path".
618
658
  *
619
659
  * @public
620
660
  */
@@ -624,6 +664,10 @@ export declare class YamlEdit extends YamlEdit_base {
624
664
  * reverse-offset order so earlier offsets stay valid; the input `edits`
625
665
  * array is not mutated. Overlapping edits are a programmer error and throw
626
666
  * as a defect — `YamlFormat` never produces them.
667
+ *
668
+ * @param text - The source text to edit.
669
+ * @param edits - The edits to apply, in any order.
670
+ * @returns The edited text.
627
671
  */
628
672
  static applyAll(text: string, edits: ReadonlyArray<YamlEdit>): string;
629
673
  }
@@ -980,6 +1024,17 @@ declare const YamlDocument_base: Schema.Class<YamlDocument, Schema.Struct<{
980
1024
  * Construct via `YamlDocument.parse` / `parseAll`; `YamlDocument.make` is for
981
1025
  * synthetic documents.
982
1026
  *
1027
+ * @example
1028
+ * ```ts
1029
+ * import { YamlDocument } from "@effected/yaml";
1030
+ * import { Effect } from "effect";
1031
+ *
1032
+ * const program = Effect.gen(function* () {
1033
+ * const doc = yield* YamlDocument.parse("# header\nname: Alice\n");
1034
+ * return doc.errors.length; // 0 — no recovered errors
1035
+ * });
1036
+ * ```
1037
+ *
983
1038
  * @public
984
1039
  */
985
1040
  export declare class YamlDocument extends YamlDocument_base {
@@ -988,12 +1043,24 @@ export declare class YamlDocument extends YamlDocument_base {
988
1043
  * recovered diagnostics. Fails with the aggregate {@link YamlParseError}
989
1044
  * when any fatal-code diagnostic is present; non-fatal diagnostics are
990
1045
  * data on the returned document.
1046
+ *
1047
+ * @param text - The YAML source to parse.
1048
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
1049
+ * omitted fields.
1050
+ * @returns An `Effect` that succeeds with the {@link YamlDocument}, or fails
1051
+ * with {@link YamlParseError}.
991
1052
  */
992
1053
  static readonly parse: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<YamlDocument, YamlParseError, never>;
993
1054
  /**
994
1055
  * Parse a multi-document YAML stream into one {@link YamlDocument} per
995
1056
  * document. Any fatal diagnostic in any document — or a stream-level
996
1057
  * directive-placement error — fails the whole Effect.
1058
+ *
1059
+ * @param text - The YAML stream to parse.
1060
+ * @param options - Optional {@link YamlParseOptions}; defaults apply for
1061
+ * omitted fields.
1062
+ * @returns An `Effect` that succeeds with one {@link YamlDocument} per
1063
+ * document, or fails with {@link YamlParseError}.
997
1064
  */
998
1065
  static readonly parseAll: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<readonly YamlDocument[], YamlParseError, never>;
999
1066
  /**
@@ -1004,6 +1071,9 @@ export declare class YamlDocument extends YamlDocument_base {
1004
1071
  * Schema-producing: each call returns a fresh schema whose derivation
1005
1072
  * caches are not shared across calls; bind the result to a `const` on hot
1006
1073
  * paths.
1074
+ *
1075
+ * @param options - Optional {@link YamlParseOptions} applied on decode.
1076
+ * @returns A `Schema.Codec<YamlDocument, string>`.
1007
1077
  */
1008
1078
  static schema(options?: YamlParseOptions): Schema.Codec<YamlDocument, string>;
1009
1079
  /**
@@ -1024,6 +1094,11 @@ export declare class YamlDocument extends YamlDocument_base {
1024
1094
  * option. Callers that need folding should render the plain value
1025
1095
  * instead — `Yaml.stringify(doc.toValue(), options)` — at the cost of
1026
1096
  * the document-level framing and styles this path preserves.
1097
+ *
1098
+ * @param options - Optional {@link YamlStringifyOptions}; defaults apply for
1099
+ * omitted fields.
1100
+ * @returns An `Effect` that succeeds with the YAML text, or fails with
1101
+ * {@link YamlStringifyError}.
1027
1102
  */
1028
1103
  stringify(options?: YamlStringifyOptions): Effect.Effect<string, YamlStringifyError>;
1029
1104
  /**
@@ -1066,8 +1141,8 @@ declare const YamlFormattingOptions_base: Schema.Class<YamlFormattingOptions, Sc
1066
1141
  * field (derived, not hand-duplicated — including `indentSequences`,
1067
1142
  * `quoteStyle` and `quoteCompat`) plus
1068
1143
  * `preserveComments` (default `true`), `range` (restrict edits to a
1069
- * region; see the module-level remarks on the `range` parameter vs. this
1070
- * field) and `requoteScalars` (default `false`).
1144
+ * region; the positional `range` argument of {@link YamlFormat.format} takes
1145
+ * precedence over this field) and `requoteScalars` (default `false`).
1071
1146
  *
1072
1147
  * `requoteScalars` makes `quoteStyle` apply to scalars **already quoted in
1073
1148
  * the source** on the format path — by default formatting preserves an
@@ -1126,7 +1201,22 @@ export declare class YamlModificationError extends YamlModificationError_base {
1126
1201
  get message(): string;
1127
1202
  }
1128
1203
  /**
1129
- * Formatting and modification statics. Not instantiable.
1204
+ * Formats YAML text and modifies values at a path as byte-minimal edits that
1205
+ * preserve comments and layout elsewhere. Not instantiable.
1206
+ *
1207
+ * @example
1208
+ * ```ts
1209
+ * import { YamlFormat } from "@effected/yaml";
1210
+ * import { Effect } from "effect";
1211
+ *
1212
+ * const formatted = YamlFormat.formatToString("a: 1\nb:\n - x\n - y # c\n");
1213
+ * // => "a: 1\nb:\n- x\n- y # c\n"
1214
+ *
1215
+ * const program = Effect.gen(function* () {
1216
+ * return yield* YamlFormat.modifyToString("port: 3000 # dev\n", ["port"], 8080);
1217
+ * // => "port: 8080 # dev\n"
1218
+ * });
1219
+ * ```
1130
1220
  *
1131
1221
  * @remarks
1132
1222
  * `format`/`formatToString` are pure and total (edit computation never fails
@@ -1152,8 +1242,8 @@ export declare class YamlModificationError extends YamlModificationError_base {
1152
1242
  * (`!e!foo`) turns a valid file into one no parser can read. So
1153
1243
  * `format`/`formatToString` leave such input byte-identical (no edits), and
1154
1244
  * `modify`/`modifyToString` fail typed with a `DirectiveCarryingDocument`
1155
- * diagnostic. Directive re-emission is unimplemented, not undesired — the
1156
- * refusal is the floor that stops corruption until it lands.
1245
+ * diagnostic. Directive re-emission is unimplemented, and the refusal is what
1246
+ * stops the corruption.
1157
1247
  *
1158
1248
  * @public
1159
1249
  */
@@ -1183,6 +1273,12 @@ export declare class YamlFormat {
1183
1273
  * directives is left untouched. Detection is directive-token-level: a
1184
1274
  * literal `%TAG` inside a scalar is content and formats normally.
1185
1275
  *
1276
+ * @param text - The YAML source to format.
1277
+ * @param range - Optional sub-range; only edits fully within it are returned.
1278
+ * @param options - Optional {@link YamlFormattingOptions}.
1279
+ * @returns The edits that bring `text` to canonical shape; apply them with
1280
+ * `YamlEdit.applyAll`. Empty when the input cannot be formatted faithfully.
1281
+ *
1186
1282
  * @remarks
1187
1283
  * The positional `range` argument takes precedence over
1188
1284
  * `options?.range` when both are given; either accepts a plain
@@ -1214,6 +1310,12 @@ export declare class YamlFormat {
1214
1310
  * document — single or in a stream — carrying `%YAML`/`%TAG` directives)
1215
1311
  * is returned byte-identical — never a truncated first document, never a
1216
1312
  * document re-emitted without the directive its tags depend on.
1313
+ *
1314
+ * @param text - The YAML source to format.
1315
+ * @param range - Optional sub-range; only edits fully within it are applied.
1316
+ * @param options - Optional {@link YamlFormattingOptions}.
1317
+ * @returns The formatted text, or `text` unchanged when it cannot be
1318
+ * formatted faithfully.
1217
1319
  */
1218
1320
  static formatToString(text: string, range?: YamlRangeLike, options?: YamlFormattingOptions): string;
1219
1321
  /**
@@ -1227,15 +1329,12 @@ export declare class YamlFormat {
1227
1329
  * sequence and any other non-null object as a block mapping over its own
1228
1330
  * enumerable string keys, recursively — the same lowering
1229
1331
  * {@link Yaml.stringify} applies to the same value, so `modify` and
1230
- * `stringify` agree on what a given JavaScript value means. (Before
1231
- * 0.14.0 only scalars were lowered and a mapping or sequence value was
1232
- * coerced through `String(value)`, writing the literal text
1233
- * `[object Object]` into the document — see #642.) For a synthesized
1332
+ * `stringify` agree on what a given JavaScript value means. For a synthesized
1234
1333
  * subtree (an object/array value) only the surrounding document is
1235
1334
  * preserved byte-for-byte; the subtree carries no comments and takes the
1236
1335
  * stringifier's styles.
1237
1336
  *
1238
- * **Scalar replacement is region-confined and quote-preserving (#659).**
1337
+ * **Scalar replacement is region-confined and quote-preserving.**
1239
1338
  * When the path resolves to an existing single-line `plain`,
1240
1339
  * `single-quoted`, or `double-quoted` scalar with no tag or anchor, and
1241
1340
  * the replacement is a string, number, or boolean, `modify` splices
@@ -1276,6 +1375,15 @@ export declare class YamlFormat {
1276
1375
  * directive re-emission is unimplemented, not undesired. A literal
1277
1376
  * `%TAG` inside a scalar is content and does not trigger the refusal.
1278
1377
  *
1378
+ * @param text - The YAML source to modify.
1379
+ * @param path - The location to insert, replace or remove.
1380
+ * @param value - The JavaScript value to write; `undefined` removes the
1381
+ * target instead.
1382
+ * @param options - Optional {@link YamlStringifyOptions} for the
1383
+ * re-stringify step.
1384
+ * @returns An `Effect` that succeeds with the edits to apply (via
1385
+ * `YamlEdit.applyAll`), or fails with {@link YamlModificationError}.
1386
+ *
1279
1387
  * @remarks
1280
1388
  * `options` is a bare {@link YamlStringifyOptions} — it controls only the
1281
1389
  * internal re-stringify step, not a range (there is no range to restrict
@@ -1288,6 +1396,15 @@ export declare class YamlFormat {
1288
1396
  * error channel, including the single-document contract's
1289
1397
  * `MultiDocumentStream` refusal and the `DirectiveCarryingDocument`
1290
1398
  * refusal of `%YAML`/`%TAG`-carrying documents.
1399
+ *
1400
+ * @param text - The YAML source to modify.
1401
+ * @param path - The location to insert, replace or remove.
1402
+ * @param value - The JavaScript value to write; `undefined` removes the
1403
+ * target instead.
1404
+ * @param options - Optional {@link YamlStringifyOptions} for the
1405
+ * re-stringify step.
1406
+ * @returns An `Effect` that succeeds with the modified text, or fails with
1407
+ * {@link YamlModificationError}.
1291
1408
  */
1292
1409
  static readonly modifyToString: (text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlModificationError, never>;
1293
1410
  }
@@ -1327,7 +1444,9 @@ declare const YamlToken_base: Schema.Class<YamlToken, Schema.Struct<{
1327
1444
  */
1328
1445
  export declare class YamlToken extends YamlToken_base {}
1329
1446
  /**
1330
- * Tokenizer statics. Not instantiable.
1447
+ * Tokenizes YAML text into positioned tokens, as a complete array or a lazy
1448
+ * `Stream`, for lint- and editor-class consumers. Never fails on malformed
1449
+ * input: lexical errors arrive as `"error"`-kind tokens. Not instantiable.
1331
1450
  *
1332
1451
  * @public
1333
1452
  */
@@ -1336,12 +1455,11 @@ export declare class YamlTokens {
1336
1455
  /**
1337
1456
  * Tokenize YAML text into the full positioned token array — the sync
1338
1457
  * `Result` primitive (tokenizing is a pure batch transform; the
1339
- * {@link YamlTokens.stream} form is derived from this one, per the kit's
1340
- * sync-primitive policy).
1458
+ * {@link YamlTokens.stream} form is derived from this one).
1341
1459
  *
1342
1460
  * @remarks
1343
- * The failure channel is **reserved** (for future input-hardening guards)
1344
- * and never fires today: the lexer is total, and lexical errors surface as
1461
+ * The failure channel is **reserved** for input-hardening guards and never
1462
+ * fires today: the lexer is total, and lexical errors surface as
1345
1463
  * `"error"`-kind tokens **in the success array** so that linting can run
1346
1464
  * on malformed input — the `parse-validity` lint rule exists precisely for
1347
1465
  * documents that do not parse. Do not "fix" this method to fail on
@@ -1357,6 +1475,9 @@ export declare class YamlTokens {
1357
1475
  * result.success.map((t) => t.kind); // ["scalar", "block-map-start", ...]
1358
1476
  * }
1359
1477
  * ```
1478
+ *
1479
+ * @param text - The YAML source to tokenize.
1480
+ * @returns A `Result` succeeding with every token in source order.
1360
1481
  */
1361
1482
  static tokenize(text: string): Result.Result<ReadonlyArray<YamlToken>, YamlParseError>;
1362
1483
  /**
@@ -1453,7 +1574,7 @@ declare const StyleVote_base: Schema.Class<StyleVote, Schema.TaggedStruct<"Style
1453
1574
  readonly character: Schema.Number;
1454
1575
  }>, {}>;
1455
1576
  /**
1456
- * One categorical style observation (#345): a single occurrence of a style
1577
+ * One categorical style observation: a single occurrence of a style
1457
1578
  * choice in the source, voting a `value` for an inference `dimension`.
1458
1579
  *
1459
1580
  * The `dimension` IS the rule's option key and the `value` IS that option's
@@ -1478,7 +1599,7 @@ declare const StyleFloor_base: Schema.Class<StyleFloor, Schema.TaggedStruct<"Sty
1478
1599
  readonly value: Schema.Number;
1479
1600
  }>, {}>;
1480
1601
  /**
1481
- * One measured style floor (#345): a value the source PROVES is at least
1602
+ * One measured style floor: a value the source PROVES is at least
1482
1603
  * `value`, without proving what the configured limit should be — the longest
1483
1604
  * observed line proves `line-length.max` is at least that long, not what it
1484
1605
  * is. Floors are carried in the evidence for callers that want them and are
@@ -1508,7 +1629,7 @@ type StyleObservation = StyleVote | StyleFloor;
1508
1629
  * rules receive options already validated against their exported options
1509
1630
  * schema, custom rules validate their own.
1510
1631
  *
1511
- * `infer` is the optional config-inference hook (#345): it reports the style
1632
+ * `infer` is the optional config-inference hook: it reports the style
1512
1633
  * the source already follows as per-occurrence {@link StyleObservation}s, so
1513
1634
  * detection logic lives beside the check logic that polices the same
1514
1635
  * dimension (and shares its fixtures). Rules with no detectable style — the
@@ -1560,9 +1681,8 @@ declare const YamlLintConfig_base: Schema.Class<YamlLintConfig, Schema.Struct<{
1560
1681
  */
1561
1682
  export declare class YamlLintConfig extends YamlLintConfig_base {
1562
1683
  /**
1563
- * The default preset. Rule entries accrete as built-ins land; the
1564
- * `quoted-strings` rule defaults to DOUBLE quotes here (the one taste
1565
- * call the design pins).
1684
+ * The default preset: the built-in rules at their default settings. The
1685
+ * `quoted-strings` rule defaults to DOUBLE quotes here.
1566
1686
  */
1567
1687
  static readonly default: YamlLintConfig;
1568
1688
  /** The relaxed preset: style rules demoted to warnings. */
@@ -1606,7 +1726,7 @@ declare const StyleEvidence_base: Schema.Class<StyleEvidence, Schema.Struct<{
1606
1726
  readonly floors: Schema.$Array<typeof StyleFloorTally>;
1607
1727
  }>, {}>;
1608
1728
  /**
1609
- * Per-dimension style evidence (#345): what the observed sources say about
1729
+ * Per-dimension style evidence: what the observed sources say about
1610
1730
  * each inferable `(rule, dimension)` — vote histograms with first-seen
1611
1731
  * positions, and measured floors.
1612
1732
  *
@@ -1681,7 +1801,25 @@ interface YamlLintInference {
1681
1801
  readonly residual: ReadonlyArray<YamlLintDiagnostic>;
1682
1802
  }
1683
1803
  /**
1684
- * Linting statics. Not instantiable.
1804
+ * Lints YAML text against a rule set, applies the rules' non-overlapping
1805
+ * fixes, and infers a lint config from the style a corpus already follows.
1806
+ * Not instantiable.
1807
+ *
1808
+ * @example
1809
+ * ```ts
1810
+ * import { YamlLint, YamlLintConfig } from "@effected/yaml";
1811
+ * import { Result } from "effect";
1812
+ *
1813
+ * const text = "a: 1\nb: 2 \n";
1814
+ *
1815
+ * const diagnostics = YamlLint.run(text, YamlLint.builtins, YamlLintConfig.default);
1816
+ * // => a colon-spacing finding on line 0 and a trailing-spaces finding on line 1 (zero-based)
1817
+ *
1818
+ * const fixed = YamlLint.fix(text, YamlLint.builtins, YamlLintConfig.default);
1819
+ * if (Result.isSuccess(fixed)) {
1820
+ * fixed.success; // "a: 1\nb: 2\n"
1821
+ * }
1822
+ * ```
1685
1823
  *
1686
1824
  * @remarks
1687
1825
  * Pure and synchronous throughout — the lint engine is the pure half only:
@@ -1712,6 +1850,12 @@ export declare class YamlLint {
1712
1850
  * literal, else `"error"`) overrides what the rule emitted, again except
1713
1851
  * for `parse-validity`, whose bridged engine diagnostics keep the
1714
1852
  * engine's own grading.
1853
+ *
1854
+ * @param text - The YAML source to lint.
1855
+ * @param rules - The rules to run, e.g. {@link YamlLint.builtins}.
1856
+ * @param config - The {@link YamlLintConfig} choosing each rule's severity
1857
+ * and options.
1858
+ * @returns Every finding, sorted by position.
1715
1859
  */
1716
1860
  static run(text: string, rules: ReadonlyArray<YamlRule>, config: YamlLintConfig): ReadonlyArray<YamlLintDiagnostic>;
1717
1861
  /**
@@ -1726,10 +1870,17 @@ export declare class YamlLint {
1726
1870
  * fixes overlap — or start at the same offset — the earlier one in
1727
1871
  * {@link YamlLint.run} order (position, then rule id) wins and the later
1728
1872
  * is dropped (its diagnostic remains reported by {@link YamlLint.run}).
1873
+ *
1874
+ * @param text - The YAML source to fix.
1875
+ * @param rules - The rules to run, e.g. {@link YamlLint.builtins}.
1876
+ * @param config - The {@link YamlLintConfig} choosing each rule's severity
1877
+ * and options.
1878
+ * @returns A `Result` succeeding with the fixed text, or failing with
1879
+ * {@link YamlParseError}.
1729
1880
  */
1730
1881
  static fix(text: string, rules: ReadonlyArray<YamlRule>, config: YamlLintConfig): Result.Result<string, YamlParseError>;
1731
1882
  /**
1732
- * Observe the style `text` already follows (#345): run every rule's
1883
+ * Observe the style `text` already follows: run every rule's
1733
1884
  * optional `infer` hook over one eagerly-built context and merge the
1734
1885
  * observations into canonical {@link StyleEvidence}. Pure and total —
1735
1886
  * strings in, evidence out; observing N files is N `observe` calls merged
@@ -2356,7 +2507,23 @@ export declare const YamlVisitorEvent: {
2356
2507
  }, "_tag">;
2357
2508
  };
2358
2509
  /**
2359
- * SAX-style YAML AST visitor statics. Not instantiable.
2510
+ * Walks YAML text as a lazy `Stream` of typed events — documents, collections,
2511
+ * pairs, scalars, aliases, comments, directives and recovered errors — in
2512
+ * document order. Not instantiable.
2513
+ *
2514
+ * @example
2515
+ * ```ts
2516
+ * import { YamlVisitor, YamlVisitorEvent } from "@effected/yaml";
2517
+ * import { Effect, Stream } from "effect";
2518
+ *
2519
+ * // Mapping keys are scalar events too, so keys and values interleave.
2520
+ * const scalars = YamlVisitor.visit("a: 1\nb:\n - x\n").pipe(
2521
+ * Stream.filter(YamlVisitorEvent.$is("Scalar")),
2522
+ * Stream.map((event) => event.value),
2523
+ * Stream.runCollect,
2524
+ * );
2525
+ * // Effect.runSync(scalars) // => ["a", 1, "b", "x"]
2526
+ * ```
2360
2527
  *
2361
2528
  * @public
2362
2529
  */
@@ -2374,6 +2541,11 @@ export declare class YamlVisitor {
2374
2541
  * (fatal or not, including an exceeded `maxAliasCount`, recorded as
2375
2542
  * `AliasCountExceeded`) surface as `Error` events inside the stream rather
2376
2543
  * than failing it.
2544
+ *
2545
+ * @param text - The YAML source to visit.
2546
+ * @param options - Optional {@link YamlParseOptions} controlling composition.
2547
+ * @returns A lazy `Stream` of `YamlVisitorEvent`, infallible at the type
2548
+ * level.
2377
2549
  */
2378
2550
  static visit(text: string, options?: YamlParseOptions): Stream.Stream<YamlVisitorEvent>;
2379
2551
  }
@@ -66,8 +66,7 @@ function composeBlockMapInner(blockMapCst, state, externalFirstKey, meta) {
66
66
  * scope re-attributes it (see `EscapedComment` in `comments.ts`: "it belongs to
67
67
  * an outer scope"). The span was the one place that disagreed, reporting an
68
68
  * `offset`/`length` whose end lay past a comment the node does not own — so a
69
- * caller splicing text at the end of the collection inserted AFTER the comment
70
- * (#642's sibling, #643).
69
+ * caller splicing text at the end of the collection inserted AFTER the comment.
71
70
  *
72
71
  * The disowned set is the input rather than a re-derived column test, so the
73
72
  * span and the comment model cannot drift apart: whatever the partition threw
@@ -534,7 +533,7 @@ function flattenBlockMapChildren(children, state, externalKeyColumn, externalKey
534
533
  * Pattern: node, value-sep (no node) produces a key:null pair.
535
534
  * Pattern: value-sep, node produces a null:value pair.
536
535
  *
537
- * Comment attribution (#127): a comment on the same line as the end of the
536
+ * Comment attribution: a comment on the same line as the end of the
538
537
  * previous pair attaches to it as the trailing `comment`; an own-line
539
538
  * comment attaches FORWARD to the next pair as `commentBefore` (consecutive
540
539
  * lines join with `\n`); a blank line before a pair (or before its
@@ -152,7 +152,7 @@ function joinComments(a, b) {
152
152
  }
153
153
  /**
154
154
  * Zero-based column of `offset` within its line. A byte-order mark at the
155
- * line start occupies no column — the lexer's convention (#694) — so a
155
+ * line start occupies no column — the lexer's convention — so a
156
156
  * BOM-prefixed root mapping's content column is `0`, not `1`, and its
157
157
  * terminal own-line comment is not mistaken for one escaping a nested map.
158
158
  */
@@ -678,9 +678,9 @@ const EMPTY_DOCUMENT = {
678
678
  hasDocumentStartTab: false
679
679
  };
680
680
  /**
681
- * Compose the first document of `text` with full error recovery — v3
682
- * `parseDocument` semantics minus the Effect wrapper and minus fatal-code
683
- * filtering (the facade applies `isFatalCode` to the returned diagnostics).
681
+ * Compose the first document of `text` with full error recovery, with no
682
+ * fatal-code filtering (the facade applies `isFatalCode` to the returned
683
+ * diagnostics).
684
684
  * Cross-document directive-placement errors are validated into the same
685
685
  * state and therefore appear in the returned document's `errors`.
686
686
  */
@@ -710,12 +710,10 @@ function composeFirstDocumentCounted(text, options) {
710
710
  };
711
711
  }
712
712
  /**
713
- * Compose every document of `text` with full error recovery — v3
714
- * `parseAllDocuments` semantics minus the Effect wrapper and minus
713
+ * Compose every document of `text` with full error recovery, with no
715
714
  * fatal-code filtering. Each document is composed with a fresh state; the
716
715
  * cross-document directive validation runs in its own state whose errors
717
- * are returned unfiltered as `streamErrors` (v3 filtered these to
718
- * `InvalidDirective` before failing — the facade applies that filter).
716
+ * are returned unfiltered as `streamErrors` (the facade applies its filter).
719
717
  */
720
718
  function composeAllDocuments(text, options) {
721
719
  const cstNodes = parseCSTAll(text);
@@ -123,7 +123,7 @@ function getBlockIndent(node) {
123
123
  * a `#` comment — body lines absorb `#` as content — and the lexer packs the
124
124
  * whole scalar (header comment included) into one CST token, so the comment
125
125
  * never surfaces as a sibling comment token for the ordinary attribution
126
- * pass (#341).
126
+ * pass.
127
127
  */
128
128
  function blockScalarHeaderComment(cst) {
129
129
  const src = cst.source.trimStart();
@@ -11,7 +11,7 @@ function getLineStarts(text) {
11
11
  }
12
12
  /**
13
13
  * Zero-based line and column of `offset`. A byte-order mark at the line start
14
- * occupies no column, matching the lexer and `columnAt` (#694), so a
14
+ * occupies no column, matching the lexer and `columnAt`, so a
15
15
  * diagnostic's `character` behind a BOM equals the BOM-less document's.
16
16
  */
17
17
  function lineCol(text, offset) {
@@ -72,9 +72,8 @@ const YAML_MODIFY_ERROR_CODES = [
72
72
  ];
73
73
  /**
74
74
  * The single source of truth for which diagnostic codes are fatal to a
75
- * parse (vs. recoverable warnings-as-data). Replaces the v3 source's three
76
- * subtly-differing inline fatal lists with their union: fatality is a
77
- * property of the code, declared once.
75
+ * parse (vs. recoverable warnings-as-data): fatality is a property of the
76
+ * code, declared once.
78
77
  */
79
78
  const FATAL_CODES = /* @__PURE__ */ new Set([
80
79
  "UndefinedAlias",
@@ -17,7 +17,7 @@ const quotedStringsOptions = Schema.Struct({
17
17
  });
18
18
  /**
19
19
  * A value-preserving requote/wrap edit, or undefined when none is safe.
20
- * Delegates to the shared helper's CONSERVATIVE mode (#347) — the shipped
20
+ * Delegates to the shared helper's CONSERVATIVE mode — the shipped
21
21
  * fix behavior stays exactly as released; the escaping-capable mode belongs
22
22
  * to the format path's opt-in `requoteScalars`, not the lint fix.
23
23
  */
@@ -138,7 +138,7 @@ function wouldBeResolved11(s) {
138
138
  * `,[]{}` are plain-unsafe anywhere in the scalar (YAML 1.2 §7.3.3,
139
139
  * `ns-plain-safe(flow-in)` excludes `c-flow-indicator`), where block context
140
140
  * lets them through. Without it a plain `p, q` rendered into `[x, y]` reads
141
- * back as three items (#695).
141
+ * back as three items.
142
142
  */
143
143
  function requiresQuoting(s, ignoreType = false, quoteCompat, inFlow = false) {
144
144
  if (s === "") return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/yaml",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "private": false,
5
5
  "description": "Zero-dependency YAML parsing, editing, formatting and linting as Effect schemas.",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "peerDependencies": {
44
- "effect": "4.0.0-rc.117"
44
+ "effect": "^4.0.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24.11.0"