@driftsys/markspec 0.4.0 → 0.6.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 +74 -20
- package/esm/ast/build.d.ts +60 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +516 -0
- package/esm/ast/equivalence.d.ts +18 -0
- package/esm/ast/equivalence.d.ts.map +1 -0
- package/esm/ast/equivalence.js +56 -0
- package/esm/ast/nodes.d.ts +189 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +17 -0
- package/esm/ast/normalize.d.ts +58 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +197 -0
- package/esm/ast/render.d.ts +34 -0
- package/esm/ast/render.d.ts.map +1 -0
- package/esm/ast/render.js +215 -0
- package/esm/compiler/constants.d.ts +16 -0
- package/esm/compiler/constants.d.ts.map +1 -0
- package/esm/compiler/constants.js +26 -0
- package/esm/compiler/discipline_classifier.d.ts +55 -0
- package/esm/compiler/discipline_classifier.d.ts.map +1 -0
- package/esm/compiler/discipline_classifier.js +191 -0
- package/esm/compiler/inverses.d.ts +2 -1
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +33 -14
- package/esm/compiler/manifest.d.ts +59 -0
- package/esm/compiler/manifest.d.ts.map +1 -0
- package/esm/compiler/manifest.js +48 -0
- package/esm/compiler/mod.d.ts +38 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +202 -50
- package/esm/compiler/ndjson_writer.d.ts +50 -0
- package/esm/compiler/ndjson_writer.d.ts.map +1 -0
- package/esm/compiler/ndjson_writer.js +73 -0
- package/esm/compiler/schema.d.ts +33 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +30 -9
- package/esm/config/markspec.d.ts +5 -0
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +17 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +55 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +423 -46
- package/esm/formatter/synth_ulid.d.ts +21 -0
- package/esm/formatter/synth_ulid.d.ts.map +1 -0
- package/esm/formatter/synth_ulid.js +64 -0
- package/esm/lexicons/loader.d.ts +35 -0
- package/esm/lexicons/loader.d.ts.map +1 -0
- package/esm/lexicons/loader.js +51 -0
- package/esm/lexicons/mod.d.ts +13 -0
- package/esm/lexicons/mod.d.ts.map +1 -0
- package/esm/lexicons/mod.js +12 -0
- package/esm/lint/glossary.d.ts +45 -0
- package/esm/lint/glossary.d.ts.map +1 -0
- package/esm/lint/glossary.js +85 -0
- package/esm/lint/mod.d.ts +14 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +9 -0
- package/esm/lint/range_util.d.ts +25 -0
- package/esm/lint/range_util.d.ts.map +1 -0
- package/esm/lint/range_util.js +50 -0
- package/esm/lint/rules/ears.d.ts +39 -0
- package/esm/lint/rules/ears.d.ts.map +1 -0
- package/esm/lint/rules/ears.js +316 -0
- package/esm/lint/rules/incose_sentence.d.ts +46 -0
- package/esm/lint/rules/incose_sentence.d.ts.map +1 -0
- package/esm/lint/rules/incose_sentence.js +417 -0
- package/esm/lint/rules/lexicon.d.ts +24 -0
- package/esm/lint/rules/lexicon.d.ts.map +1 -0
- package/esm/lint/rules/lexicon.js +236 -0
- package/esm/lint/rules/modal_sentence.d.ts +46 -0
- package/esm/lint/rules/modal_sentence.d.ts.map +1 -0
- package/esm/lint/rules/modal_sentence.js +146 -0
- package/esm/lint/rules/passive.d.ts +64 -0
- package/esm/lint/rules/passive.d.ts.map +1 -0
- package/esm/lint/rules/passive.js +282 -0
- package/esm/lint/rules/struct.d.ts +17 -0
- package/esm/lint/rules/struct.d.ts.map +1 -0
- package/esm/lint/rules/struct.js +55 -0
- package/esm/lint/rules/suppression.d.ts +54 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +129 -0
- package/esm/lint/rules/xref.d.ts +19 -0
- package/esm/lint/rules/xref.d.ts.map +1 -0
- package/esm/lint/rules/xref.js +248 -0
- package/esm/lint/runner.d.ts +59 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +153 -0
- package/esm/lint/score.d.ts +64 -0
- package/esm/lint/score.d.ts.map +1 -0
- package/esm/lint/score.js +163 -0
- package/esm/lint/segmenter.d.ts +32 -0
- package/esm/lint/segmenter.d.ts.map +1 -0
- package/esm/lint/segmenter.js +79 -0
- package/esm/lint/types.d.ts +31 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/lock/canonical_edges.d.ts +31 -0
- package/esm/lock/canonical_edges.d.ts.map +1 -0
- package/esm/lock/canonical_edges.js +57 -0
- package/esm/lock/check.d.ts +24 -0
- package/esm/lock/check.d.ts.map +1 -0
- package/esm/lock/check.js +127 -0
- package/esm/lock/hash.d.ts +12 -0
- package/esm/lock/hash.d.ts.map +1 -0
- package/esm/lock/hash.js +32 -0
- package/esm/lock/mod.d.ts +19 -0
- package/esm/lock/mod.d.ts.map +1 -0
- package/esm/lock/mod.js +14 -0
- package/esm/lock/model.d.ts +81 -0
- package/esm/lock/model.d.ts.map +1 -0
- package/esm/lock/model.js +7 -0
- package/esm/lock/parser.d.ts +26 -0
- package/esm/lock/parser.d.ts.map +1 -0
- package/esm/lock/parser.js +195 -0
- package/esm/lock/resolve.d.ts +142 -0
- package/esm/lock/resolve.d.ts.map +1 -0
- package/esm/lock/resolve.js +389 -0
- package/esm/lock/serializer.d.ts +14 -0
- package/esm/lock/serializer.d.ts.map +1 -0
- package/esm/lock/serializer.js +104 -0
- package/esm/mod.d.ts +28 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +23 -4
- package/esm/model/attributes.d.ts +6 -0
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +200 -2
- package/esm/model/discipline.d.ts +53 -0
- package/esm/model/discipline.d.ts.map +1 -0
- package/esm/model/discipline.js +50 -0
- package/esm/model/discriminating_attr.d.ts +33 -0
- package/esm/model/discriminating_attr.d.ts.map +1 -0
- package/esm/model/discriminating_attr.js +74 -0
- package/esm/model/mod.d.ts +267 -14
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +99 -3
- package/esm/model/profile.d.ts +102 -27
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/model/source_introspection.d.ts +26 -0
- package/esm/model/source_introspection.d.ts.map +1 -0
- package/esm/model/source_introspection.js +77 -0
- package/esm/model/type_hierarchy.d.ts +51 -0
- package/esm/model/type_hierarchy.d.ts.map +1 -0
- package/esm/model/type_hierarchy.js +126 -0
- package/esm/model/uri_scheme_map.d.ts +21 -0
- package/esm/model/uri_scheme_map.d.ts.map +1 -0
- package/esm/model/uri_scheme_map.js +66 -0
- package/esm/parser/attributes.d.ts.map +1 -1
- package/esm/parser/attributes.js +10 -16
- package/esm/parser/body_tokens.d.ts +35 -0
- package/esm/parser/body_tokens.d.ts.map +1 -0
- package/esm/parser/body_tokens.js +232 -0
- package/esm/parser/glossary.d.ts +51 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +219 -0
- package/esm/parser/grammars.d.ts +5 -3
- package/esm/parser/grammars.d.ts.map +1 -1
- package/esm/parser/grammars.js +12 -4
- package/esm/parser/language_spec.d.ts +55 -0
- package/esm/parser/language_spec.d.ts.map +1 -0
- package/esm/parser/language_spec.js +419 -0
- package/esm/parser/line_map.d.ts +60 -0
- package/esm/parser/line_map.d.ts.map +1 -0
- package/esm/parser/line_map.js +41 -0
- package/esm/parser/markdown.d.ts +9 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +317 -25
- package/esm/parser/mod.d.ts +5 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +31 -8
- package/esm/parser/source.d.ts +53 -2
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +158 -68
- package/esm/parser/translate.d.ts +24 -0
- package/esm/parser/translate.d.ts.map +1 -0
- package/esm/parser/translate.js +99 -0
- package/esm/profile/chain.d.ts +8 -0
- package/esm/profile/chain.d.ts.map +1 -1
- package/esm/profile/chain.js +32 -14
- package/esm/profile/colors.js +1 -1
- package/esm/profile/default_profile.d.ts +25 -0
- package/esm/profile/default_profile.d.ts.map +1 -0
- package/esm/profile/default_profile.js +43 -0
- package/esm/profile/discipline_mode.d.ts +64 -0
- package/esm/profile/discipline_mode.d.ts.map +1 -0
- package/esm/profile/discipline_mode.js +133 -0
- package/esm/profile/discipline_registry.d.ts +41 -0
- package/esm/profile/discipline_registry.d.ts.map +1 -0
- package/esm/profile/discipline_registry.js +67 -0
- package/esm/profile/introspect.d.ts +135 -0
- package/esm/profile/introspect.d.ts.map +1 -0
- package/esm/profile/introspect.js +378 -0
- package/esm/profile/load.d.ts +3 -1
- package/esm/profile/load.d.ts.map +1 -1
- package/esm/profile/load.js +91 -5
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +512 -90
- package/esm/profile/merge.d.ts.map +1 -1
- package/esm/profile/merge.js +251 -39
- package/esm/profile/mod.d.ts +4 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +7 -2
- package/esm/reporter/mod.js +4 -4
- package/esm/sync/locked_attributes.d.ts +19 -0
- package/esm/sync/locked_attributes.d.ts.map +1 -0
- package/esm/sync/locked_attributes.js +27 -0
- package/esm/sync/log.d.ts +34 -0
- package/esm/sync/log.d.ts.map +1 -0
- package/esm/sync/log.js +48 -0
- package/esm/sync/mapping.d.ts +66 -0
- package/esm/sync/mapping.d.ts.map +1 -0
- package/esm/sync/mapping.js +165 -0
- package/esm/sync/mod.d.ts +16 -0
- package/esm/sync/mod.d.ts.map +1 -0
- package/esm/sync/mod.js +12 -0
- package/esm/sync/status.d.ts +23 -0
- package/esm/sync/status.d.ts.map +1 -0
- package/esm/sync/status.js +21 -0
- package/esm/typl/ast.d.ts +87 -0
- package/esm/typl/ast.d.ts.map +1 -0
- package/esm/typl/ast.js +21 -0
- package/esm/typl/bridge.d.ts +32 -0
- package/esm/typl/bridge.d.ts.map +1 -0
- package/esm/typl/bridge.js +27 -0
- package/esm/typl/bullet.d.ts +34 -0
- package/esm/typl/bullet.d.ts.map +1 -0
- package/esm/typl/bullet.js +44 -0
- package/esm/typl/diagnostics.d.ts +43 -0
- package/esm/typl/diagnostics.d.ts.map +1 -0
- package/esm/typl/diagnostics.js +61 -0
- package/esm/typl/fence.d.ts +31 -0
- package/esm/typl/fence.d.ts.map +1 -0
- package/esm/typl/fence.js +24 -0
- package/esm/typl/grammar.d.ts +20 -0
- package/esm/typl/grammar.d.ts.map +1 -0
- package/esm/typl/grammar.js +471 -0
- package/esm/typl/inline.d.ts +34 -0
- package/esm/typl/inline.d.ts.map +1 -0
- package/esm/typl/inline.js +48 -0
- package/esm/typl/lexer.d.ts +37 -0
- package/esm/typl/lexer.d.ts.map +1 -0
- package/esm/typl/lexer.js +234 -0
- package/esm/typl/mod.d.ts +23 -0
- package/esm/typl/mod.d.ts.map +1 -0
- package/esm/typl/mod.js +16 -0
- package/esm/typl/registry.d.ts +42 -0
- package/esm/typl/registry.d.ts.map +1 -0
- package/esm/typl/registry.js +26 -0
- package/esm/typl/validator.d.ts +29 -0
- package/esm/typl/validator.d.ts.map +1 -0
- package/esm/typl/validator.js +141 -0
- package/esm/util/fence.d.ts +30 -0
- package/esm/util/fence.d.ts.map +1 -0
- package/esm/util/fence.js +40 -0
- package/esm/util/line_endings.d.ts +33 -0
- package/esm/util/line_endings.d.ts.map +1 -0
- package/esm/util/line_endings.js +53 -0
- package/esm/util/modals.d.ts +29 -0
- package/esm/util/modals.d.ts.map +1 -0
- package/esm/util/modals.js +38 -0
- package/esm/validator/attributes.d.ts +3 -3
- package/esm/validator/attributes.d.ts.map +1 -1
- package/esm/validator/attributes.js +1 -18
- package/esm/validator/body_blocks.d.ts +38 -0
- package/esm/validator/body_blocks.d.ts.map +1 -0
- package/esm/validator/body_blocks.js +218 -0
- package/esm/validator/caption_convention.d.ts +29 -0
- package/esm/validator/caption_convention.d.ts.map +1 -0
- package/esm/validator/caption_convention.js +58 -0
- package/esm/validator/captions.d.ts +22 -0
- package/esm/validator/captions.d.ts.map +1 -0
- package/esm/validator/captions.js +137 -0
- package/esm/validator/component_schemes.d.ts +73 -0
- package/esm/validator/component_schemes.d.ts.map +1 -0
- package/esm/validator/component_schemes.js +375 -0
- package/esm/validator/discipline.d.ts +35 -0
- package/esm/validator/discipline.d.ts.map +1 -0
- package/esm/validator/discipline.js +204 -0
- package/esm/validator/feature_ac.d.ts +28 -0
- package/esm/validator/feature_ac.d.ts.map +1 -0
- package/esm/validator/feature_ac.js +102 -0
- package/esm/validator/listing.d.ts +42 -0
- package/esm/validator/listing.d.ts.map +1 -0
- package/esm/validator/listing.js +295 -0
- package/esm/validator/mod.d.ts +3 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +275 -13
- package/esm/validator/modal_keywords.d.ts +25 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +54 -0
- package/esm/validator/pattern.d.ts +15 -8
- package/esm/validator/pattern.d.ts.map +1 -1
- package/esm/validator/pattern.js +42 -19
- package/esm/validator/per_type_attrs.d.ts +29 -0
- package/esm/validator/per_type_attrs.d.ts.map +1 -0
- package/esm/validator/per_type_attrs.js +75 -0
- package/esm/validator/pipeline.d.ts +18 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +76 -21
- package/esm/validator/trace_types.d.ts +26 -0
- package/esm/validator/trace_types.d.ts.map +1 -0
- package/esm/validator/trace_types.js +232 -0
- package/esm/validator/traceability.d.ts +3 -4
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +5 -10
- package/esm/validator/type_resolution.d.ts +67 -0
- package/esm/validator/type_resolution.d.ts.map +1 -0
- package/esm/validator/type_resolution.js +162 -0
- package/esm/validator/types.d.ts +45 -0
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +128 -16
- package/esm/validator/value_types.d.ts +8 -0
- package/esm/validator/value_types.d.ts.map +1 -1
- package/esm/validator/value_types.js +8 -1
- package/package.json +2 -2
- package/script/ast/build.d.ts +60 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +521 -0
- package/script/ast/equivalence.d.ts +18 -0
- package/script/ast/equivalence.d.ts.map +1 -0
- package/script/ast/equivalence.js +59 -0
- package/script/ast/nodes.d.ts +189 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +18 -0
- package/script/ast/normalize.d.ts +58 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +200 -0
- package/script/ast/render.d.ts +34 -0
- package/script/ast/render.d.ts.map +1 -0
- package/script/ast/render.js +218 -0
- package/script/compiler/constants.d.ts +16 -0
- package/script/compiler/constants.d.ts.map +1 -0
- package/script/compiler/constants.js +29 -0
- package/script/compiler/discipline_classifier.d.ts +55 -0
- package/script/compiler/discipline_classifier.d.ts.map +1 -0
- package/script/compiler/discipline_classifier.js +196 -0
- package/script/compiler/inverses.d.ts +2 -1
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +33 -14
- package/script/compiler/manifest.d.ts +59 -0
- package/script/compiler/manifest.d.ts.map +1 -0
- package/script/compiler/manifest.js +51 -0
- package/script/compiler/mod.d.ts +38 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +206 -54
- package/script/compiler/ndjson_writer.d.ts +50 -0
- package/script/compiler/ndjson_writer.d.ts.map +1 -0
- package/script/compiler/ndjson_writer.js +78 -0
- package/script/compiler/schema.d.ts +33 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +30 -8
- package/script/config/markspec.d.ts +5 -0
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +17 -2
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +55 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +426 -46
- package/script/formatter/synth_ulid.d.ts +21 -0
- package/script/formatter/synth_ulid.d.ts.map +1 -0
- package/script/formatter/synth_ulid.js +67 -0
- package/script/lexicons/loader.d.ts +35 -0
- package/script/lexicons/loader.d.ts.map +1 -0
- package/script/lexicons/loader.js +55 -0
- package/script/lexicons/mod.d.ts +13 -0
- package/script/lexicons/mod.d.ts.map +1 -0
- package/script/lexicons/mod.js +17 -0
- package/script/lint/glossary.d.ts +45 -0
- package/script/lint/glossary.d.ts.map +1 -0
- package/script/lint/glossary.js +88 -0
- package/script/lint/mod.d.ts +14 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +17 -0
- package/script/lint/range_util.d.ts +25 -0
- package/script/lint/range_util.d.ts.map +1 -0
- package/script/lint/range_util.js +53 -0
- package/script/lint/rules/ears.d.ts +39 -0
- package/script/lint/rules/ears.d.ts.map +1 -0
- package/script/lint/rules/ears.js +320 -0
- package/script/lint/rules/incose_sentence.d.ts +46 -0
- package/script/lint/rules/incose_sentence.d.ts.map +1 -0
- package/script/lint/rules/incose_sentence.js +421 -0
- package/script/lint/rules/lexicon.d.ts +24 -0
- package/script/lint/rules/lexicon.d.ts.map +1 -0
- package/script/lint/rules/lexicon.js +240 -0
- package/script/lint/rules/modal_sentence.d.ts +46 -0
- package/script/lint/rules/modal_sentence.d.ts.map +1 -0
- package/script/lint/rules/modal_sentence.js +150 -0
- package/script/lint/rules/passive.d.ts +64 -0
- package/script/lint/rules/passive.d.ts.map +1 -0
- package/script/lint/rules/passive.js +286 -0
- package/script/lint/rules/struct.d.ts +17 -0
- package/script/lint/rules/struct.d.ts.map +1 -0
- package/script/lint/rules/struct.js +59 -0
- package/script/lint/rules/suppression.d.ts +54 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +136 -0
- package/script/lint/rules/xref.d.ts +19 -0
- package/script/lint/rules/xref.d.ts.map +1 -0
- package/script/lint/rules/xref.js +251 -0
- package/script/lint/runner.d.ts +59 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +157 -0
- package/script/lint/score.d.ts +64 -0
- package/script/lint/score.d.ts.map +1 -0
- package/script/lint/score.js +167 -0
- package/script/lint/segmenter.d.ts +32 -0
- package/script/lint/segmenter.d.ts.map +1 -0
- package/script/lint/segmenter.js +82 -0
- package/script/lint/types.d.ts +31 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/lock/canonical_edges.d.ts +31 -0
- package/script/lock/canonical_edges.d.ts.map +1 -0
- package/script/lock/canonical_edges.js +61 -0
- package/script/lock/check.d.ts +24 -0
- package/script/lock/check.d.ts.map +1 -0
- package/script/lock/check.js +130 -0
- package/script/lock/hash.d.ts +12 -0
- package/script/lock/hash.d.ts.map +1 -0
- package/script/lock/hash.js +36 -0
- package/script/lock/mod.d.ts +19 -0
- package/script/lock/mod.d.ts.map +1 -0
- package/script/lock/mod.js +31 -0
- package/script/lock/model.d.ts +81 -0
- package/script/lock/model.d.ts.map +1 -0
- package/script/lock/model.js +10 -0
- package/script/lock/parser.d.ts +26 -0
- package/script/lock/parser.d.ts.map +1 -0
- package/script/lock/parser.js +198 -0
- package/script/lock/resolve.d.ts +142 -0
- package/script/lock/resolve.d.ts.map +1 -0
- package/script/lock/resolve.js +397 -0
- package/script/lock/serializer.d.ts +14 -0
- package/script/lock/serializer.d.ts.map +1 -0
- package/script/lock/serializer.js +107 -0
- package/script/mod.d.ts +28 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +129 -32
- package/script/model/attributes.d.ts +6 -0
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +201 -3
- package/script/model/discipline.d.ts +53 -0
- package/script/model/discipline.d.ts.map +1 -0
- package/script/model/discipline.js +53 -0
- package/script/model/discriminating_attr.d.ts +33 -0
- package/script/model/discriminating_attr.d.ts.map +1 -0
- package/script/model/discriminating_attr.js +77 -0
- package/script/model/mod.d.ts +267 -14
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +111 -3
- package/script/model/profile.d.ts +102 -27
- package/script/model/profile.d.ts.map +1 -1
- package/script/model/source_introspection.d.ts +26 -0
- package/script/model/source_introspection.d.ts.map +1 -0
- package/script/model/source_introspection.js +80 -0
- package/script/model/type_hierarchy.d.ts +51 -0
- package/script/model/type_hierarchy.d.ts.map +1 -0
- package/script/model/type_hierarchy.js +130 -0
- package/script/model/uri_scheme_map.d.ts +21 -0
- package/script/model/uri_scheme_map.d.ts.map +1 -0
- package/script/model/uri_scheme_map.js +69 -0
- package/script/parser/attributes.d.ts.map +1 -1
- package/script/parser/attributes.js +10 -16
- package/script/parser/body_tokens.d.ts +35 -0
- package/script/parser/body_tokens.d.ts.map +1 -0
- package/script/parser/body_tokens.js +235 -0
- package/script/parser/glossary.d.ts +51 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +224 -0
- package/script/parser/grammars.d.ts +5 -3
- package/script/parser/grammars.d.ts.map +1 -1
- package/script/parser/grammars.js +15 -8
- package/script/parser/language_spec.d.ts +55 -0
- package/script/parser/language_spec.d.ts.map +1 -0
- package/script/parser/language_spec.js +423 -0
- package/script/parser/line_map.d.ts +60 -0
- package/script/parser/line_map.d.ts.map +1 -0
- package/script/parser/line_map.js +44 -0
- package/script/parser/markdown.d.ts +9 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +315 -23
- package/script/parser/mod.d.ts +5 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +36 -7
- package/script/parser/source.d.ts +53 -2
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +159 -69
- package/script/parser/translate.d.ts +24 -0
- package/script/parser/translate.d.ts.map +1 -0
- package/script/parser/translate.js +102 -0
- package/script/profile/chain.d.ts +8 -0
- package/script/profile/chain.d.ts.map +1 -1
- package/script/profile/chain.js +32 -14
- package/script/profile/colors.js +1 -1
- package/script/profile/default_profile.d.ts +25 -0
- package/script/profile/default_profile.d.ts.map +1 -0
- package/script/profile/default_profile.js +46 -0
- package/script/profile/discipline_mode.d.ts +64 -0
- package/script/profile/discipline_mode.d.ts.map +1 -0
- package/script/profile/discipline_mode.js +138 -0
- package/script/profile/discipline_registry.d.ts +41 -0
- package/script/profile/discipline_registry.d.ts.map +1 -0
- package/script/profile/discipline_registry.js +70 -0
- package/script/profile/introspect.d.ts +135 -0
- package/script/profile/introspect.d.ts.map +1 -0
- package/script/profile/introspect.js +381 -0
- package/script/profile/load.d.ts +3 -1
- package/script/profile/load.d.ts.map +1 -1
- package/script/profile/load.js +91 -5
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +511 -89
- package/script/profile/merge.d.ts.map +1 -1
- package/script/profile/merge.js +251 -39
- package/script/profile/mod.d.ts +4 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +12 -6
- package/script/reporter/mod.js +4 -4
- package/script/sync/locked_attributes.d.ts +19 -0
- package/script/sync/locked_attributes.d.ts.map +1 -0
- package/script/sync/locked_attributes.js +30 -0
- package/script/sync/log.d.ts +34 -0
- package/script/sync/log.d.ts.map +1 -0
- package/script/sync/log.js +52 -0
- package/script/sync/mapping.d.ts +66 -0
- package/script/sync/mapping.d.ts.map +1 -0
- package/script/sync/mapping.js +169 -0
- package/script/sync/mod.d.ts +16 -0
- package/script/sync/mod.d.ts.map +1 -0
- package/script/sync/mod.js +21 -0
- package/script/sync/status.d.ts +23 -0
- package/script/sync/status.d.ts.map +1 -0
- package/script/sync/status.js +24 -0
- package/script/typl/ast.d.ts +87 -0
- package/script/typl/ast.d.ts.map +1 -0
- package/script/typl/ast.js +24 -0
- package/script/typl/bridge.d.ts +32 -0
- package/script/typl/bridge.d.ts.map +1 -0
- package/script/typl/bridge.js +30 -0
- package/script/typl/bullet.d.ts +34 -0
- package/script/typl/bullet.d.ts.map +1 -0
- package/script/typl/bullet.js +47 -0
- package/script/typl/diagnostics.d.ts +43 -0
- package/script/typl/diagnostics.d.ts.map +1 -0
- package/script/typl/diagnostics.js +65 -0
- package/script/typl/fence.d.ts +31 -0
- package/script/typl/fence.d.ts.map +1 -0
- package/script/typl/fence.js +27 -0
- package/script/typl/grammar.d.ts +20 -0
- package/script/typl/grammar.d.ts.map +1 -0
- package/script/typl/grammar.js +474 -0
- package/script/typl/inline.d.ts +34 -0
- package/script/typl/inline.d.ts.map +1 -0
- package/script/typl/inline.js +51 -0
- package/script/typl/lexer.d.ts +37 -0
- package/script/typl/lexer.d.ts.map +1 -0
- package/script/typl/lexer.js +237 -0
- package/script/typl/mod.d.ts +23 -0
- package/script/typl/mod.d.ts.map +1 -0
- package/script/typl/mod.js +29 -0
- package/script/typl/registry.d.ts +42 -0
- package/script/typl/registry.d.ts.map +1 -0
- package/script/typl/registry.js +29 -0
- package/script/typl/validator.d.ts +29 -0
- package/script/typl/validator.d.ts.map +1 -0
- package/script/typl/validator.js +144 -0
- package/script/util/fence.d.ts +30 -0
- package/script/util/fence.d.ts.map +1 -0
- package/script/util/fence.js +44 -0
- package/script/util/line_endings.d.ts +33 -0
- package/script/util/line_endings.d.ts.map +1 -0
- package/script/util/line_endings.js +58 -0
- package/script/util/modals.d.ts +29 -0
- package/script/util/modals.d.ts.map +1 -0
- package/script/util/modals.js +42 -0
- package/script/validator/attributes.d.ts +3 -3
- package/script/validator/attributes.d.ts.map +1 -1
- package/script/validator/attributes.js +1 -18
- package/script/validator/body_blocks.d.ts +38 -0
- package/script/validator/body_blocks.d.ts.map +1 -0
- package/script/validator/body_blocks.js +221 -0
- package/script/validator/caption_convention.d.ts +29 -0
- package/script/validator/caption_convention.d.ts.map +1 -0
- package/script/validator/caption_convention.js +61 -0
- package/script/validator/captions.d.ts +22 -0
- package/script/validator/captions.d.ts.map +1 -0
- package/script/validator/captions.js +140 -0
- package/script/validator/component_schemes.d.ts +73 -0
- package/script/validator/component_schemes.d.ts.map +1 -0
- package/script/validator/component_schemes.js +384 -0
- package/script/validator/discipline.d.ts +35 -0
- package/script/validator/discipline.d.ts.map +1 -0
- package/script/validator/discipline.js +207 -0
- package/script/validator/feature_ac.d.ts +28 -0
- package/script/validator/feature_ac.d.ts.map +1 -0
- package/script/validator/feature_ac.js +105 -0
- package/script/validator/listing.d.ts +42 -0
- package/script/validator/listing.d.ts.map +1 -0
- package/script/validator/listing.js +298 -0
- package/script/validator/mod.d.ts +3 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +278 -14
- package/script/validator/modal_keywords.d.ts +25 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +57 -0
- package/script/validator/pattern.d.ts +15 -8
- package/script/validator/pattern.d.ts.map +1 -1
- package/script/validator/pattern.js +42 -19
- package/script/validator/per_type_attrs.d.ts +29 -0
- package/script/validator/per_type_attrs.d.ts.map +1 -0
- package/script/validator/per_type_attrs.js +78 -0
- package/script/validator/pipeline.d.ts +18 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +78 -22
- package/script/validator/trace_types.d.ts +26 -0
- package/script/validator/trace_types.d.ts.map +1 -0
- package/script/validator/trace_types.js +235 -0
- package/script/validator/traceability.d.ts +3 -4
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +5 -10
- package/script/validator/type_resolution.d.ts +67 -0
- package/script/validator/type_resolution.d.ts.map +1 -0
- package/script/validator/type_resolution.js +168 -0
- package/script/validator/types.d.ts +45 -0
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +131 -16
- package/script/validator/value_types.d.ts +8 -0
- package/script/validator/value_types.d.ts.map +1 -1
- package/script/validator/value_types.js +10 -2
package/script/formatter/mod.js
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
* and requirement block insertion.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.isSentenceInitial = isSentenceInitial;
|
|
11
|
+
exports.normalizeModalKeywords = normalizeModalKeywords;
|
|
10
12
|
exports.format = format;
|
|
11
13
|
exports.expandCsvValues = expandCsvValues;
|
|
14
|
+
exports.canonicalizeKey = canonicalizeKey;
|
|
12
15
|
exports.sortAttributes = sortAttributes;
|
|
13
16
|
exports.renderAttributeBlock = renderAttributeBlock;
|
|
14
17
|
exports.findAttributeBlockRange = findAttributeBlockRange;
|
|
@@ -18,16 +21,58 @@ const mod_js_1 = require("../model/mod.js");
|
|
|
18
21
|
const attributes_js_1 = require("../parser/attributes.js");
|
|
19
22
|
const frontmatter_js_1 = require("../parser/frontmatter.js");
|
|
20
23
|
const markdown_js_1 = require("../parser/markdown.js");
|
|
24
|
+
const fence_js_1 = require("../util/fence.js");
|
|
25
|
+
const line_endings_js_1 = require("../util/line_endings.js");
|
|
26
|
+
const modals_js_1 = require("../util/modals.js");
|
|
27
|
+
const synth_ulid_js_1 = require("./synth_ulid.js");
|
|
28
|
+
const build_js_1 = require("../ast/build.js");
|
|
29
|
+
const render_js_1 = require("../ast/render.js");
|
|
30
|
+
const normalize_js_1 = require("../ast/normalize.js");
|
|
31
|
+
const equivalence_js_1 = require("../ast/equivalence.js");
|
|
21
32
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
33
|
+
* Decide whether the EARS keyword at `offset` in `line` is at sentence
|
|
34
|
+
* start (return value true). Delegates to the shared implementation in
|
|
35
|
+
* `core/util/modals.ts`; re-exported here for backward compatibility with
|
|
36
|
+
* existing callers and tests that import from `formatter/mod.ts`.
|
|
25
37
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
function isSentenceInitial(line, offset) {
|
|
39
|
+
return (0, modals_js_1.isSentenceInitial)(line, offset);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalise modal keywords to canonical case in body prose (§3.4.1):
|
|
43
|
+
*
|
|
44
|
+
* - RFC 2119 (`SHALL`, `SHOULD`, `MAY`, `MUST`, optionally `… NOT`) —
|
|
45
|
+
* always lowercased.
|
|
46
|
+
* - EARS (`When`, `While`, `Where`, `Unless`) — lowercased mid-sentence,
|
|
47
|
+
* preserved sentence-initial.
|
|
48
|
+
*
|
|
49
|
+
* The pass skips:
|
|
50
|
+
*
|
|
51
|
+
* - Fenced code blocks (between paired ``` or ~~~ markers) — code is
|
|
52
|
+
* verbatim per round-trip invariants (spec §5.1).
|
|
53
|
+
* - Lines indented by four or more spaces (or a tab) — conservatively
|
|
54
|
+
* captures indented code blocks and attribute trailers, both of which
|
|
55
|
+
* are not prose.
|
|
56
|
+
*
|
|
57
|
+
* @remarks Not called by `format()` as of SP3 Task 5 — body modal
|
|
58
|
+
* normalization moved to `normalizeBodyAst` in the AST pass (spec-correct
|
|
59
|
+
* verbatim-boundary handling). Retained as an exported symbol because
|
|
60
|
+
* `mod_test.ts` tests it directly and `core/ast/normalize.ts` documents
|
|
61
|
+
* the intentional duplication until a follow-up collapses the two. Do NOT
|
|
62
|
+
* delete — external callers may depend on this export.
|
|
63
|
+
*/
|
|
64
|
+
function normalizeModalKeywords(markdown) {
|
|
65
|
+
const lines = markdown.split("\n");
|
|
66
|
+
(0, fence_js_1.walkProseLines)(markdown, (line, i) => {
|
|
67
|
+
// Indented-code / attribute-trailer lines aren't prose either.
|
|
68
|
+
if (/^( {4}|\t)/.test(line))
|
|
69
|
+
return;
|
|
70
|
+
let normalized = line.replace(modals_js_1.RFC2119_MODAL_RE, (m) => m.toLowerCase());
|
|
71
|
+
normalized = normalized.replace(modals_js_1.EARS_KEYWORD_RE, (m, _g1, offset) => isSentenceInitial(normalized, offset) ? m : m.toLowerCase());
|
|
72
|
+
lines[i] = normalized;
|
|
73
|
+
});
|
|
74
|
+
return lines.join("\n");
|
|
75
|
+
}
|
|
31
76
|
/**
|
|
32
77
|
* Canonical front-matter key order per ADR-007. Core keys first, then
|
|
33
78
|
* `metadata` (reserved free-form map), then `extra` (allowlisted ecosystem
|
|
@@ -43,29 +88,228 @@ const FRONT_MATTER_CORE_ORDER = [
|
|
|
43
88
|
"references",
|
|
44
89
|
];
|
|
45
90
|
/**
|
|
46
|
-
* Canonical
|
|
91
|
+
* Canonical trailer ordering per spec §3.3.2 (six-group rule).
|
|
47
92
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
93
|
+
* Groups, top → bottom:
|
|
94
|
+
* 1. Identity & classification — `Id`, `Type`, `Source`, `Origin`.
|
|
95
|
+
* 2. Reference-shape navigation — `Reference-document`, `Reference-url`.
|
|
96
|
+
* 3. Trace upstream relations — authored trace edges (`Part-of`,
|
|
97
|
+
* `Derived-from`, `Satisfies`, …).
|
|
98
|
+
* 4. Type-specific data — payload attributes per concrete type
|
|
99
|
+
* (`Schema-language`, `License`, `Manufacturer`, …).
|
|
100
|
+
* 5. Universal trailing — `References`, `External-id`, `Labels`,
|
|
101
|
+
* `Supersedes`, `Deprecated`.
|
|
102
|
+
* 6. Profile-declared / unknown attributes — preserved in source order
|
|
103
|
+
* at the bottom (§3.3.6: fmt never deletes a key it doesn't own).
|
|
53
104
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
105
|
+
* Generated-origin attributes (`Superseded-by`, every inverse from ADR-003
|
|
106
|
+
* §Part 3) are stripped from this list; the formatter rejects them with
|
|
107
|
+
* MSL-A030 when found in source (current code keeps `Superseded-by:` to
|
|
108
|
+
* round-trip historical fixtures — that hardening lands in a later slice).
|
|
57
109
|
*/
|
|
58
110
|
const CANONICAL_ORDER = [
|
|
111
|
+
// Group 1 — identity & classification
|
|
59
112
|
"Id",
|
|
60
|
-
|
|
61
|
-
|
|
113
|
+
"Type",
|
|
114
|
+
"Source",
|
|
115
|
+
"Origin",
|
|
116
|
+
// Group 2 — reference-shape navigation
|
|
117
|
+
"Reference-document",
|
|
118
|
+
"Reference-url",
|
|
119
|
+
// Group 3 — trace upstream (authored relations)
|
|
120
|
+
"Part-of",
|
|
121
|
+
"Derived-from",
|
|
122
|
+
"Satisfies",
|
|
123
|
+
"Verifies",
|
|
124
|
+
"Tests",
|
|
125
|
+
"Realizes",
|
|
126
|
+
"Provides",
|
|
127
|
+
"Requires",
|
|
128
|
+
"Depends-on",
|
|
129
|
+
"Caused-by",
|
|
130
|
+
"Mitigated-by",
|
|
131
|
+
"Allocated-to",
|
|
132
|
+
"Affects",
|
|
133
|
+
// Group 4 — type-specific data
|
|
134
|
+
"Schema-language",
|
|
135
|
+
"License",
|
|
136
|
+
"Build-manifest",
|
|
137
|
+
"Package-manager",
|
|
138
|
+
"Manufacturer",
|
|
139
|
+
"Part-number",
|
|
140
|
+
"Datasheet",
|
|
141
|
+
"Bus-protocol",
|
|
142
|
+
"Connector-type",
|
|
143
|
+
"Voltage-level",
|
|
144
|
+
"Signal-direction",
|
|
145
|
+
"Symbol",
|
|
146
|
+
"Language",
|
|
147
|
+
"Footprint",
|
|
148
|
+
"Value",
|
|
149
|
+
"Aliases",
|
|
150
|
+
"See-also",
|
|
151
|
+
// Group 5 — universal trailing
|
|
62
152
|
"References",
|
|
63
|
-
"Labels",
|
|
64
153
|
"External-id",
|
|
154
|
+
"Labels",
|
|
65
155
|
"Supersedes",
|
|
66
156
|
"Superseded-by",
|
|
67
157
|
"Deprecated",
|
|
158
|
+
// Group 6 — profile-declared / unknown keys are appended in source order
|
|
159
|
+
// after this list by sortAttributes().
|
|
68
160
|
];
|
|
161
|
+
/**
|
|
162
|
+
* Post-pass: route each entry's body through the canonical body-AST
|
|
163
|
+
* (the load-bearing §5.2 emission path — SP3 Task 5 cutover).
|
|
164
|
+
*
|
|
165
|
+
* Called on the post-collapse `lines` array (after attribute-block
|
|
166
|
+
* splicing and `collapseBlankLines`). The body modal-keyword §3.4.1
|
|
167
|
+
* pass is NO LONGER applied as a pre-parse whole-body string pass; it
|
|
168
|
+
* is now AST-native via `normalizeBodyAst` here (more spec-correct:
|
|
169
|
+
* the AST pass respects §2.5 verbatim boundaries and per-node
|
|
170
|
+
* sentence-initial context that the whole-body string pass could get
|
|
171
|
+
* wrong inside Code/Math blocks). Re-parses the lines to get entries
|
|
172
|
+
* with correct post-collapse line numbers, then for each entry:
|
|
173
|
+
*
|
|
174
|
+
* 1. Takes `entry.body` — the body string from the parser
|
|
175
|
+
* (indent-stripped, trimmed, attrs split off).
|
|
176
|
+
* 2. Builds the body AST, applies `normalizeBodyAst` (the §3.4.1 /
|
|
177
|
+
* §5.2 canonicalization pass), and emits via `render`.
|
|
178
|
+
* 3. Guards the emit with the formal §5 `astEquivalent` relation:
|
|
179
|
+
* `render`-ing the emitted body and re-building must be AST-equal
|
|
180
|
+
* to the canonical AST. If not, this is an SP3 residual — keep
|
|
181
|
+
* the original body lines untouched and raise a LOUD diagnostic
|
|
182
|
+
* (MSL-F900). This branch is RETAINED for safety; over the
|
|
183
|
+
* idempotence corpus and real project docs it never fires.
|
|
184
|
+
* 4. Reconstructs the body segment in `lines` from the emitted
|
|
185
|
+
* string, preserving the leading/trailing blank-line delimiters
|
|
186
|
+
* that separate the body from the title and attr block.
|
|
187
|
+
*
|
|
188
|
+
* Returns `true` when any entry body was rewritten (so `format()` can
|
|
189
|
+
* keep `changed` accurate for `--check` mode); `false` when every body
|
|
190
|
+
* was already §5.2-canonical.
|
|
191
|
+
*
|
|
192
|
+
* `Entry.body` stays `string`; no other module is affected.
|
|
193
|
+
* `normalizeBodyAst` is FORMATTER-ONLY — the validate/parse path must
|
|
194
|
+
* never call it.
|
|
195
|
+
*/
|
|
196
|
+
function emitBodyViaAst(lines, file, diagnostics, cachedEntries) {
|
|
197
|
+
// When the caller supplies pre-parsed entries whose line numbers are still
|
|
198
|
+
// valid in `lines` (i.e., no line-count-changing operations occurred before
|
|
199
|
+
// this call), skip the re-parse entirely — the common hot path for files
|
|
200
|
+
// that are already in canonical form. When the caller passes undefined the
|
|
201
|
+
// re-parse is performed as before.
|
|
202
|
+
let entries;
|
|
203
|
+
if (cachedEntries !== undefined) {
|
|
204
|
+
entries = cachedEntries;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// Diagnostics from this re-parse are intentionally discarded: the
|
|
208
|
+
// input is already canonical (post-collapse) output.
|
|
209
|
+
({ entries } = (0, markdown_js_1.parseMarkdown)(lines.join("\n"), { file }));
|
|
210
|
+
}
|
|
211
|
+
if (entries.length === 0)
|
|
212
|
+
return false;
|
|
213
|
+
let bodyChanged = false;
|
|
214
|
+
// Process bottom-to-top so splices don't shift earlier entry positions.
|
|
215
|
+
const sorted = [...entries].sort((a, b) => b.location.line - a.location.line);
|
|
216
|
+
for (const entry of sorted) {
|
|
217
|
+
if (!entry.body.trim())
|
|
218
|
+
continue; // empty or whitespace-only body
|
|
219
|
+
const indent = (entry.location.column - 1) + 2; // marker column (0-based) + 2 spaces = list-item continuation indent
|
|
220
|
+
const indentStr = " ".repeat(indent);
|
|
221
|
+
const titleLineIdx = entry.location.line - 1; // 0-based
|
|
222
|
+
// Locate the body segment in `lines` — between the title line and
|
|
223
|
+
// the attr block start (or item end when there is no attr block).
|
|
224
|
+
const range = findAttributeBlockRange(lines, entry.location.line, indent);
|
|
225
|
+
const bodyStart = titleLineIdx + 1;
|
|
226
|
+
const bodyEnd = range
|
|
227
|
+
? range.start
|
|
228
|
+
: findItemEnd(lines, titleLineIdx, indent);
|
|
229
|
+
if (bodyEnd <= bodyStart)
|
|
230
|
+
continue; // no body lines to replace
|
|
231
|
+
// Route the body through the canonical AST: build → normalize
|
|
232
|
+
// (§3.4.1 / §5.2) → render. The §5 equivalence relation guards the
|
|
233
|
+
// emit; `render`+`build` is the inverse on canonical input for
|
|
234
|
+
// every body shape under the equivalence gate.
|
|
235
|
+
const ast0 = (0, build_js_1.buildBodyAst)(entry.body);
|
|
236
|
+
const canonical = (0, normalize_js_1.normalizeBodyAst)(ast0);
|
|
237
|
+
const emittedBody = (0, render_js_1.render)(canonical);
|
|
238
|
+
if (!(0, equivalence_js_1.astEquivalent)((0, build_js_1.buildBodyAst)(emittedBody), canonical)) {
|
|
239
|
+
// SP3 residual. The build/render inverse is not yet total over
|
|
240
|
+
// every valid Markdown body construct; for a body where the
|
|
241
|
+
// emitted form does not re-build AST-equivalent to the canonical
|
|
242
|
+
// AST we cannot guarantee a lossless §5.2 re-emission. Keep the
|
|
243
|
+
// original body lines EXACTLY as-is — zero corruption, zero
|
|
244
|
+
// spurious rewrites — and raise a LOUD diagnostic so the residual
|
|
245
|
+
// is visible (it never fires over the idempotence corpus or real
|
|
246
|
+
// project docs). This safe-fallback branch is RETAINED by design;
|
|
247
|
+
// only its criterion changed (byte-identity → astEquivalent) and
|
|
248
|
+
// it now diagnoses instead of silently degrading.
|
|
249
|
+
diagnostics.push({
|
|
250
|
+
code: "MSL-F900",
|
|
251
|
+
severity: "error",
|
|
252
|
+
message: `${entry.displayId}: body not AST-equivalent after ` +
|
|
253
|
+
`canonicalization (SP3 residual — formatter kept the ` +
|
|
254
|
+
`original body)`,
|
|
255
|
+
location: entry.location,
|
|
256
|
+
});
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
// The emitted body is the §5.2-canonical body and re-builds
|
|
260
|
+
// AST-equivalent to the canonical AST. Splice it back into the
|
|
261
|
+
// document — the AST is the load-bearing emission path.
|
|
262
|
+
// Reconstruct the body segment: re-add the continuation indent to
|
|
263
|
+
// each non-blank line, preserving the blank-line delimiters that
|
|
264
|
+
// separate the body from the title and attr block.
|
|
265
|
+
const rawSegment = lines.slice(bodyStart, bodyEnd);
|
|
266
|
+
// Preserve the blank delimiter lines at the start/end of the segment.
|
|
267
|
+
const leadBlanks = [];
|
|
268
|
+
const trailBlanks = [];
|
|
269
|
+
let si = 0;
|
|
270
|
+
while (si < rawSegment.length && rawSegment[si].trim() === "") {
|
|
271
|
+
leadBlanks.push(rawSegment[si++]);
|
|
272
|
+
}
|
|
273
|
+
let ei = rawSegment.length - 1;
|
|
274
|
+
while (ei >= si && rawSegment[ei].trim() === "") {
|
|
275
|
+
trailBlanks.unshift(rawSegment[ei--]);
|
|
276
|
+
}
|
|
277
|
+
const emittedLines = emittedBody.split("\n").map((l) => l ? `${indentStr}${l}` : l);
|
|
278
|
+
const newSegment = [...leadBlanks, ...emittedLines, ...trailBlanks];
|
|
279
|
+
// `changed` accuracy: only flag a body rewrite when the spliced
|
|
280
|
+
// segment actually differs from the original lines (a §5.2-canonical
|
|
281
|
+
// body splices back byte-identically — a pure no-op).
|
|
282
|
+
if (newSegment.length !== rawSegment.length ||
|
|
283
|
+
newSegment.some((l, i) => l !== rawSegment[i])) {
|
|
284
|
+
bodyChanged = true;
|
|
285
|
+
}
|
|
286
|
+
lines.splice(bodyStart, bodyEnd - bodyStart, ...newSegment);
|
|
287
|
+
}
|
|
288
|
+
return bodyChanged;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* UTC `YYYY-MM-DD` for today. Used as the default for the
|
|
292
|
+
* Discipline-frozen: stamper.
|
|
293
|
+
*/
|
|
294
|
+
function todayUtc() {
|
|
295
|
+
return new Date().toISOString().slice(0, 10);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* If `value` is a bare discipline kind (no `@`), return
|
|
299
|
+
* `<kind> @ <today>`. Otherwise return the value unchanged. Used by
|
|
300
|
+
* `format()` to auto-stamp `Discipline-frozen:` lines per ADR-017 Slice 3.
|
|
301
|
+
*
|
|
302
|
+
* The bare-kind regex deliberately matches the same shape the validator
|
|
303
|
+
* accepts in {@linkcode parseFrozenValue}; anything that doesn't match
|
|
304
|
+
* (e.g. uppercase kinds, already-dated forms) is left alone — the
|
|
305
|
+
* validator handles malformed values via MSL-T026.
|
|
306
|
+
*/
|
|
307
|
+
function stampDisciplineFrozen(value, today) {
|
|
308
|
+
if (/^[a-z][a-z0-9-]*\s*$/.test(value)) {
|
|
309
|
+
return `${value.trim()} @ ${today}`;
|
|
310
|
+
}
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
69
313
|
/**
|
|
70
314
|
* Format a Markdown string — normalize attribute blocks,
|
|
71
315
|
* fix indentation, enforce canonical ordering.
|
|
@@ -76,13 +320,30 @@ const CANONICAL_ORDER = [
|
|
|
76
320
|
*/
|
|
77
321
|
function format(markdown, options) {
|
|
78
322
|
const file = options?.file ?? "<unknown>";
|
|
323
|
+
// Detect the source file's line-ending convention up front so we can
|
|
324
|
+
// restore it on write-back. The rest of the formatter operates on a
|
|
325
|
+
// pure-LF buffer; any `\r` characters from a CRLF (or legacy Mac CR)
|
|
326
|
+
// source would otherwise leak into trailers and AST nodes.
|
|
327
|
+
const sourceLineEnding = (0, line_endings_js_1.detectLineEnding)(markdown);
|
|
328
|
+
const normalisedMarkdown = sourceLineEnding === "lf"
|
|
329
|
+
? markdown
|
|
330
|
+
: (0, line_endings_js_1.normalizeLineEndings)(markdown);
|
|
79
331
|
// Extract any YAML front matter first so entries are parsed against the
|
|
80
332
|
// body only (front-matter `---` could be confused with horizontal rules).
|
|
81
|
-
const fm = (0, frontmatter_js_1.extractFrontMatter)(
|
|
82
|
-
const
|
|
333
|
+
const fm = (0, frontmatter_js_1.extractFrontMatter)(normalisedMarkdown, { file });
|
|
334
|
+
const rawBody = fm.hadFrontMatter ? fm.markdown : normalisedMarkdown;
|
|
335
|
+
// The §3.4.1 modal-keyword pass is NO LONGER a pre-parse whole-body
|
|
336
|
+
// string pass. It is AST-native in `emitBodyViaAst` via
|
|
337
|
+
// `normalizeBodyAst` (more spec-correct: respects §2.5 verbatim
|
|
338
|
+
// boundaries and per-node sentence-initial context). `normalizeModalKeywords`
|
|
339
|
+
// stays exported/defined for other callers/tests but is not invoked here.
|
|
340
|
+
const body = rawBody;
|
|
83
341
|
const { entries } = (0, markdown_js_1.parseMarkdown)(body, { file });
|
|
84
342
|
const diagnostics = [...fm.diagnostics];
|
|
85
343
|
if (entries.length === 0 && !fm.hadFrontMatter) {
|
|
344
|
+
// No entries and no front matter — nothing to format. Returning the
|
|
345
|
+
// original `markdown` preserves the source's exact byte sequence,
|
|
346
|
+
// including its line-ending convention.
|
|
86
347
|
return { output: markdown, diagnostics, changed: false };
|
|
87
348
|
}
|
|
88
349
|
const lines = body.split("\n");
|
|
@@ -93,12 +354,37 @@ function format(markdown, options) {
|
|
|
93
354
|
for (const entry of sorted) {
|
|
94
355
|
const indent = (entry.location.column - 1) + 2;
|
|
95
356
|
let attrs = [...entry.rawAttributes];
|
|
357
|
+
// Title-line bullet canonicalisation per spec §3.2: rewrite `*`
|
|
358
|
+
// or `+` to `-`. The list-item position from the parser is the
|
|
359
|
+
// line carrying the bullet marker; we only touch the marker
|
|
360
|
+
// character itself, leaving the rest of the title alone.
|
|
361
|
+
const titleLineIdx = entry.location.line - 1;
|
|
362
|
+
if (titleLineIdx >= 0 && titleLineIdx < lines.length) {
|
|
363
|
+
const titleLine = lines[titleLineIdx];
|
|
364
|
+
const markerCol = entry.location.column - 1;
|
|
365
|
+
const markerChar = titleLine.charAt(markerCol);
|
|
366
|
+
if (markerChar === "*" || markerChar === "+") {
|
|
367
|
+
lines[titleLineIdx] = titleLine.slice(0, markerCol) +
|
|
368
|
+
"-" + titleLine.slice(markerCol + 1);
|
|
369
|
+
changed = true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
96
372
|
// Assign a bare ULID `Id:` to identified entries that carry no
|
|
97
373
|
// identity yet. Referenced entries are left alone — their `Id:` is a
|
|
98
374
|
// URI that must be author-provided.
|
|
375
|
+
//
|
|
376
|
+
// For `Origin: synthesized` entries (spec §3.5), derive the ULID
|
|
377
|
+
// deterministically from `Source:` so re-running `fmt` on the same
|
|
378
|
+
// input reproduces the same identity. Falls back to fresh random
|
|
379
|
+
// when `Source:` is missing — synthesizing without a source pointer
|
|
380
|
+
// makes no sense, but the formatter never fails a stamp.
|
|
99
381
|
const hasIdentity = attrs.some((a) => a.key === mod_js_1.IDENTITY_KEY);
|
|
100
|
-
if (!hasIdentity && entry.shape === "
|
|
101
|
-
const
|
|
382
|
+
if (!hasIdentity && entry.shape === "Authored") {
|
|
383
|
+
const origin = attrs.find((a) => a.key === "Origin")?.value.trim();
|
|
384
|
+
const source = attrs.find((a) => a.key === "Source")?.value.trim();
|
|
385
|
+
const newId = origin === "synthesized" && source && source.length > 0
|
|
386
|
+
? (0, synth_ulid_js_1.synthesizedUlid)(source)
|
|
387
|
+
: genUlid();
|
|
102
388
|
attrs = [{ key: mod_js_1.IDENTITY_KEY, value: newId }, ...attrs];
|
|
103
389
|
diagnostics.push({
|
|
104
390
|
code: "MSL-F001",
|
|
@@ -107,6 +393,31 @@ function format(markdown, options) {
|
|
|
107
393
|
location: entry.location,
|
|
108
394
|
});
|
|
109
395
|
}
|
|
396
|
+
// Discipline-frozen: date stamping (ADR-017 Slice 3). Walk attrs;
|
|
397
|
+
// if any Discipline-frozen: value is a bare kind, rewrite it with
|
|
398
|
+
// today's UTC date. Idempotent on already-dated values.
|
|
399
|
+
const todayFn = options?.today ?? todayUtc;
|
|
400
|
+
const todayStr = todayFn();
|
|
401
|
+
let stampedCount = 0;
|
|
402
|
+
attrs = attrs.map((a) => {
|
|
403
|
+
if (a.key !== "Discipline-frozen")
|
|
404
|
+
return a;
|
|
405
|
+
const newValue = stampDisciplineFrozen(a.value, todayStr);
|
|
406
|
+
if (newValue !== a.value) {
|
|
407
|
+
stampedCount++;
|
|
408
|
+
return { key: a.key, value: newValue };
|
|
409
|
+
}
|
|
410
|
+
return a;
|
|
411
|
+
});
|
|
412
|
+
if (stampedCount > 0) {
|
|
413
|
+
diagnostics.push({
|
|
414
|
+
code: "MSL-F001",
|
|
415
|
+
severity: "info",
|
|
416
|
+
message: `stamped Discipline-frozen: with ${todayStr} on ${entry.displayId}`,
|
|
417
|
+
location: entry.location,
|
|
418
|
+
});
|
|
419
|
+
changed = true;
|
|
420
|
+
}
|
|
110
421
|
if (attrs.length === 0)
|
|
111
422
|
continue;
|
|
112
423
|
const normalized = sortAttributes(expandCsvValues(attrs));
|
|
@@ -128,15 +439,41 @@ function format(markdown, options) {
|
|
|
128
439
|
changed = true;
|
|
129
440
|
}
|
|
130
441
|
}
|
|
131
|
-
|
|
442
|
+
// Spec §3.4.3 / §5.2 — collapse consecutive blank lines to one.
|
|
443
|
+
// Runs after entry-block splicing so the in-progress line indices
|
|
444
|
+
// stay aligned with parser-reported positions. Operates inside
|
|
445
|
+
// fenced code regions only outside-code; verbatim regions keep
|
|
446
|
+
// their blank-line counts.
|
|
447
|
+
const collapsedLines = collapseBlankLines(lines);
|
|
448
|
+
if (collapsedLines.length !== lines.length)
|
|
449
|
+
changed = true;
|
|
450
|
+
// SP3 §5.2-via-AST cutover: route each entry's body through the
|
|
451
|
+
// canonical AST — build → normalizeBodyAst (§3.4.1 / §5.2) → render,
|
|
452
|
+
// guarded by the formal §5 `astEquivalent` relation. This is the
|
|
453
|
+
// load-bearing body-emission path AND the body modal-keyword pass
|
|
454
|
+
// (the pre-parse whole-body string pass was removed above). It
|
|
455
|
+
// returns whether any body was rewritten so `changed` stays accurate
|
|
456
|
+
// for `--check`.
|
|
457
|
+
//
|
|
458
|
+
// D6 optimization: when neither attribute-block splicing nor blank-line
|
|
459
|
+
// collapse altered any line positions, the first-parse entry line numbers
|
|
460
|
+
// are still valid in `collapsedLines` — pass the cached entries so
|
|
461
|
+
// emitBodyViaAst skips its re-parse (the hot path for already-formatted
|
|
462
|
+
// files). When `changed` is true, any splicing or collapse may have
|
|
463
|
+
// shifted positions, so pass undefined to trigger the normal re-parse.
|
|
464
|
+
if (emitBodyViaAst(collapsedLines, file, diagnostics, changed ? undefined : entries))
|
|
465
|
+
changed = true;
|
|
466
|
+
const formattedBody = collapsedLines.join("\n");
|
|
132
467
|
if (fm.hadFrontMatter) {
|
|
133
468
|
const canonicalFm = renderFrontMatter(fm.attributes);
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
469
|
+
const outputLf = canonicalFm + formattedBody;
|
|
470
|
+
if (outputLf !== normalisedMarkdown)
|
|
136
471
|
changed = true;
|
|
472
|
+
const output = (0, line_endings_js_1.applyLineEnding)(outputLf, sourceLineEnding);
|
|
137
473
|
return { output, diagnostics, changed };
|
|
138
474
|
}
|
|
139
|
-
|
|
475
|
+
const output = (0, line_endings_js_1.applyLineEnding)(formattedBody, sourceLineEnding);
|
|
476
|
+
return { output, diagnostics, changed };
|
|
140
477
|
}
|
|
141
478
|
/**
|
|
142
479
|
* Render {@linkcode DocumentAttributes} as a canonical YAML front matter
|
|
@@ -164,6 +501,36 @@ function renderFrontMatter(attrs) {
|
|
|
164
501
|
const yaml = (0, yaml_1.stringify)(ordered).trimEnd();
|
|
165
502
|
return `---\n${yaml}\n---\n\n`;
|
|
166
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Collapse consecutive blank lines to a single blank line per spec
|
|
506
|
+
* §3.4.3 (caption boundary) / §5.2 (general body rule). Fenced code
|
|
507
|
+
* regions are preserved verbatim — blank-line counts inside fenced
|
|
508
|
+
* blocks are author intent, not noise.
|
|
509
|
+
*/
|
|
510
|
+
function collapseBlankLines(lines) {
|
|
511
|
+
const out = [];
|
|
512
|
+
let inFence = false;
|
|
513
|
+
let prevBlank = false;
|
|
514
|
+
for (const line of lines) {
|
|
515
|
+
if (fence_js_1.FENCE_RE.test(line)) {
|
|
516
|
+
out.push(line);
|
|
517
|
+
inFence = !inFence;
|
|
518
|
+
prevBlank = false;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
if (inFence) {
|
|
522
|
+
out.push(line);
|
|
523
|
+
prevBlank = false;
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
const isBlank = line.trim() === "";
|
|
527
|
+
if (isBlank && prevBlank)
|
|
528
|
+
continue;
|
|
529
|
+
out.push(line);
|
|
530
|
+
prevBlank = isBlank;
|
|
531
|
+
}
|
|
532
|
+
return out;
|
|
533
|
+
}
|
|
167
534
|
/**
|
|
168
535
|
* Expand CSV values on repeatable-type attributes into one entry per value
|
|
169
536
|
* per ADR-002 §2.6. `id-list` / `tag-list` / `external-id` accept CSV input
|
|
@@ -174,7 +541,7 @@ function expandCsvValues(attrs) {
|
|
|
174
541
|
const result = [];
|
|
175
542
|
for (const attr of attrs) {
|
|
176
543
|
const spec = (0, mod_js_1.attributeSpec)(attr.key);
|
|
177
|
-
if (spec && CSV_SPLITTABLE_TYPES.has(spec.type) && attr.value.includes(",")) {
|
|
544
|
+
if (spec && mod_js_1.CSV_SPLITTABLE_TYPES.has(spec.type) && attr.value.includes(",")) {
|
|
178
545
|
const values = attr.value
|
|
179
546
|
.split(",")
|
|
180
547
|
.map((s) => s.trim())
|
|
@@ -190,43 +557,56 @@ function expandCsvValues(attrs) {
|
|
|
190
557
|
return result;
|
|
191
558
|
}
|
|
192
559
|
/**
|
|
193
|
-
*
|
|
560
|
+
* Canonicalise a trailer key to TitleCase-Hyphenated per spec §3.3.4.
|
|
561
|
+
* First character of the key uppercase, every other character
|
|
562
|
+
* lowercase; hyphens preserved. Examples (from the spec):
|
|
563
|
+
*
|
|
564
|
+
* `Id`, `Derived-from`, `Reference-url`, `Bus-protocol`.
|
|
565
|
+
*
|
|
566
|
+
* Inputs like `ID`, `BUS-PROTOCOL`, `reference-URL`, `Derived-From`
|
|
567
|
+
* all canonicalise to the spec form regardless of casing in source.
|
|
568
|
+
*/
|
|
569
|
+
function canonicalizeKey(key) {
|
|
570
|
+
if (key.length === 0)
|
|
571
|
+
return key;
|
|
572
|
+
return key[0].toUpperCase() + key.slice(1).toLowerCase();
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Sort attributes to canonical trailer order per spec §3.3.2 and
|
|
576
|
+
* re-case each key per spec §3.3.4.
|
|
194
577
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
578
|
+
* Known core keys appear in their {@linkcode CANONICAL_ORDER} slot
|
|
579
|
+
* (lookup is case-insensitive via {@linkcode canonicalizeKey}).
|
|
580
|
+
* Unknown / profile-declared keys (group 6) are appended at the end
|
|
581
|
+
* in source order — `fmt` never deletes a key it doesn't own
|
|
582
|
+
* (§3.3.6). Every emitted attribute carries the canonical key form.
|
|
198
583
|
*/
|
|
199
584
|
function sortAttributes(attributes) {
|
|
200
585
|
const known = new Array(CANONICAL_ORDER.length);
|
|
201
586
|
const unknown = [];
|
|
202
587
|
for (const attr of attributes) {
|
|
203
|
-
const
|
|
588
|
+
const canonical = canonicalizeKey(attr.key);
|
|
589
|
+
const recased = canonical === attr.key
|
|
590
|
+
? attr
|
|
591
|
+
: { ...attr, key: canonical };
|
|
592
|
+
const idx = CANONICAL_ORDER.indexOf(canonical);
|
|
204
593
|
if (idx >= 0) {
|
|
205
594
|
// Preserve duplicates — keep all occurrences of the same key.
|
|
206
595
|
if (!known[idx])
|
|
207
596
|
known[idx] = [];
|
|
208
|
-
known[idx].push(
|
|
597
|
+
known[idx].push(recased);
|
|
209
598
|
}
|
|
210
599
|
else {
|
|
211
|
-
unknown.push(
|
|
600
|
+
unknown.push(recased);
|
|
212
601
|
}
|
|
213
602
|
}
|
|
214
603
|
const result = [];
|
|
215
|
-
const labelsIdx = CANONICAL_ORDER.indexOf("Labels");
|
|
216
|
-
const hasLabels = known[labelsIdx] != null;
|
|
217
604
|
for (let i = 0; i < known.length; i++) {
|
|
218
|
-
// Insert unknown attributes just before Labels (or at end if no Labels).
|
|
219
|
-
if (i === labelsIdx && hasLabels) {
|
|
220
|
-
result.push(...unknown);
|
|
221
|
-
}
|
|
222
605
|
if (known[i] != null) {
|
|
223
606
|
result.push(...known[i]);
|
|
224
607
|
}
|
|
225
608
|
}
|
|
226
|
-
|
|
227
|
-
if (!hasLabels) {
|
|
228
|
-
result.push(...unknown);
|
|
229
|
-
}
|
|
609
|
+
result.push(...unknown);
|
|
230
610
|
return result;
|
|
231
611
|
}
|
|
232
612
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/formatter/synth_ulid
|
|
3
|
+
*
|
|
4
|
+
* Deterministic synthesized-ULID derivation per spec §3.5:
|
|
5
|
+
*
|
|
6
|
+
* ULID(timestamp=0, randomness=truncate(SHA-256(canonical(Source)), 80))
|
|
7
|
+
*
|
|
8
|
+
* Used by the formatter when an Authored entry carries `Origin:
|
|
9
|
+
* synthesized` — the ULID becomes a content-addressed fingerprint of the
|
|
10
|
+
* source pointer, so re-running `fmt` against an already-synthesized
|
|
11
|
+
* entry reproduces the same `Id:`. Authored (default) origin keeps using
|
|
12
|
+
* a fresh random ULID.
|
|
13
|
+
*
|
|
14
|
+
* Uses `node:crypto` rather than Web Crypto so the function stays
|
|
15
|
+
* synchronous; the formatter's public API is sync and threading async
|
|
16
|
+
* through every call site would be a much larger change for no benefit
|
|
17
|
+
* (the hash is bounded by a single short string).
|
|
18
|
+
*/
|
|
19
|
+
/** Derive a deterministic ULID from a `Source:` value. */
|
|
20
|
+
export declare function synthesizedUlid(source: string): string;
|
|
21
|
+
//# sourceMappingURL=synth_ulid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synth_ulid.d.ts","sourceRoot":"","sources":["../../src/formatter/synth_ulid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAgDH,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKtD"}
|