@driftsys/markspec 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/esm/compiler/deserialize.d.ts +49 -0
- package/esm/compiler/deserialize.d.ts.map +1 -0
- package/esm/compiler/deserialize.js +139 -0
- package/esm/compiler/manifest.d.ts +3 -0
- package/esm/compiler/manifest.d.ts.map +1 -1
- package/esm/compiler/manifest.js +9 -3
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +16 -7
- package/esm/config/markspec.d.ts +38 -1
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +127 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +143 -147
- package/esm/decl/duplicates.d.ts +29 -0
- package/esm/decl/duplicates.d.ts.map +1 -0
- package/esm/decl/duplicates.js +28 -0
- package/esm/decl/mod.d.ts +4 -2
- package/esm/decl/mod.d.ts.map +1 -1
- package/esm/decl/mod.js +2 -1
- package/esm/decl/surfaces.d.ts +29 -7
- package/esm/decl/surfaces.d.ts.map +1 -1
- package/esm/decl/surfaces.js +31 -18
- package/esm/gates/mod.d.ts +13 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +38 -11
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +3 -1
- package/esm/lock/acquire_compile.d.ts +31 -0
- package/esm/lock/acquire_compile.d.ts.map +1 -0
- package/esm/lock/acquire_compile.js +83 -0
- package/esm/lock/cache_check.d.ts +28 -0
- package/esm/lock/cache_check.d.ts.map +1 -0
- package/esm/lock/cache_check.js +51 -0
- package/esm/lock/check.d.ts +14 -3
- package/esm/lock/check.d.ts.map +1 -1
- package/esm/lock/check.js +41 -3
- package/esm/lock/git_intent.d.ts +46 -0
- package/esm/lock/git_intent.d.ts.map +1 -0
- package/esm/lock/git_intent.js +111 -0
- package/esm/lock/mod.d.ts +10 -3
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +7 -1
- package/esm/lock/model.d.ts +24 -1
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +32 -0
- package/esm/lock/pin_assurance.d.ts +20 -0
- package/esm/lock/pin_assurance.d.ts.map +1 -0
- package/esm/lock/pin_assurance.js +34 -0
- package/esm/lock/resolve.d.ts +8 -17
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +7 -67
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +23 -0
- package/esm/lock/upstream_common.d.ts +29 -0
- package/esm/lock/upstream_common.d.ts.map +1 -0
- package/esm/lock/upstream_common.js +38 -0
- package/esm/lock/upstream_deps.d.ts +63 -0
- package/esm/lock/upstream_deps.d.ts.map +1 -0
- package/esm/lock/upstream_deps.js +172 -0
- package/esm/lock/upstream_refs.d.ts +69 -0
- package/esm/lock/upstream_refs.d.ts.map +1 -0
- package/esm/lock/upstream_refs.js +238 -0
- package/esm/mod.d.ts +16 -8
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +15 -5
- package/esm/model/mod.d.ts +93 -28
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +66 -13
- package/esm/model/profile.d.ts +13 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +7 -51
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +20 -3
- package/esm/profile/merge.js +7 -0
- package/esm/reporter/mod.d.ts +11 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +19 -8
- package/esm/typl/assemble.d.ts +53 -0
- package/esm/typl/assemble.d.ts.map +1 -0
- package/esm/typl/assemble.js +238 -0
- package/esm/typl/ast.d.ts +7 -1
- package/esm/typl/ast.d.ts.map +1 -1
- package/esm/typl/ast.js +3 -0
- package/esm/typl/bullet.d.ts +9 -7
- package/esm/typl/bullet.d.ts.map +1 -1
- package/esm/typl/bullet.js +6 -4
- package/esm/typl/citations.d.ts +27 -0
- package/esm/typl/citations.d.ts.map +1 -0
- package/esm/typl/citations.js +16 -0
- package/esm/typl/diagnostics.d.ts +2 -2
- package/esm/typl/diagnostics.d.ts.map +1 -1
- package/esm/typl/diagnostics.js +18 -0
- package/esm/typl/grammar.d.ts.map +1 -1
- package/esm/typl/grammar.js +6 -0
- package/esm/typl/lexer.d.ts.map +1 -1
- package/esm/typl/lexer.js +25 -4
- package/esm/typl/mod.d.ts +8 -2
- package/esm/typl/mod.d.ts.map +1 -1
- package/esm/typl/mod.js +5 -1
- package/esm/typl/recognize.js +2 -2
- package/esm/typl/registry.d.ts +1 -1
- package/esm/typl/resolve.d.ts +31 -0
- package/esm/typl/resolve.d.ts.map +1 -0
- package/esm/typl/resolve.js +27 -0
- package/esm/typl/table.d.ts +52 -0
- package/esm/typl/table.d.ts.map +1 -0
- package/esm/typl/table.js +69 -0
- package/esm/typl/validator.d.ts +24 -5
- package/esm/typl/validator.d.ts.map +1 -1
- package/esm/typl/validator.js +55 -75
- package/esm/upstream/mod.d.ts +45 -0
- package/esm/upstream/mod.d.ts.map +1 -0
- package/esm/upstream/mod.js +98 -0
- package/esm/upstream/project.d.ts +33 -0
- package/esm/upstream/project.d.ts.map +1 -0
- package/esm/upstream/project.js +38 -0
- package/esm/upstream/refs.d.ts +23 -0
- package/esm/upstream/refs.d.ts.map +1 -0
- package/esm/upstream/refs.js +71 -0
- package/esm/util/paths.d.ts +14 -0
- package/esm/util/paths.d.ts.map +1 -0
- package/esm/util/paths.js +22 -0
- package/esm/uxil/assemble.d.ts +38 -0
- package/esm/uxil/assemble.d.ts.map +1 -0
- package/esm/uxil/assemble.js +268 -0
- package/esm/uxil/ast.d.ts +63 -0
- package/esm/uxil/ast.d.ts.map +1 -0
- package/esm/uxil/ast.js +9 -0
- package/esm/uxil/citations.d.ts +27 -0
- package/esm/uxil/citations.d.ts.map +1 -0
- package/esm/uxil/citations.js +25 -0
- package/esm/uxil/diagnostics.d.ts +39 -0
- package/esm/uxil/diagnostics.d.ts.map +1 -0
- package/esm/uxil/diagnostics.js +135 -0
- package/esm/uxil/grammar.d.ts +72 -0
- package/esm/uxil/grammar.d.ts.map +1 -0
- package/esm/uxil/grammar.js +505 -0
- package/esm/uxil/lexer.d.ts +23 -0
- package/esm/uxil/lexer.d.ts.map +1 -0
- package/esm/uxil/lexer.js +58 -0
- package/esm/uxil/mod.d.ts +32 -0
- package/esm/uxil/mod.d.ts.map +1 -0
- package/esm/uxil/mod.js +11 -0
- package/esm/uxil/projection.d.ts +40 -0
- package/esm/uxil/projection.d.ts.map +1 -0
- package/esm/uxil/projection.js +41 -0
- package/esm/uxil/recognize.d.ts +16 -0
- package/esm/uxil/recognize.d.ts.map +1 -0
- package/esm/uxil/recognize.js +28 -0
- package/esm/uxil/registry.d.ts +37 -0
- package/esm/uxil/registry.d.ts.map +1 -0
- package/esm/uxil/registry.js +29 -0
- package/esm/uxil/surfaces.d.ts +36 -0
- package/esm/uxil/surfaces.d.ts.map +1 -0
- package/esm/uxil/surfaces.js +34 -0
- package/esm/uxil/validator.d.ts +36 -0
- package/esm/uxil/validator.d.ts.map +1 -0
- package/esm/uxil/validator.js +139 -0
- package/esm/uxil/vocab.d.ts +33 -0
- package/esm/uxil/vocab.d.ts.map +1 -0
- package/esm/uxil/vocab.js +36 -0
- package/esm/validator/caption_convention.d.ts +2 -1
- package/esm/validator/caption_convention.d.ts.map +1 -1
- package/esm/validator/caption_convention.js +2 -1
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +40 -17
- package/esm/validator/discipline.d.ts +6 -4
- package/esm/validator/discipline.d.ts.map +1 -1
- package/esm/validator/discipline.js +6 -4
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +28 -15
- package/esm/validator/pipeline.d.ts +11 -1
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +68 -18
- package/esm/validator/trace_types.d.ts +9 -2
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +21 -5
- package/esm/validator/traceability.d.ts +15 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +39 -4
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +11 -1
- package/esm/validator/uxil_family.d.ts +43 -0
- package/esm/validator/uxil_family.d.ts.map +1 -0
- package/esm/validator/uxil_family.js +52 -0
- package/package.json +1 -1
- package/script/compiler/deserialize.d.ts +49 -0
- package/script/compiler/deserialize.d.ts.map +1 -0
- package/script/compiler/deserialize.js +144 -0
- package/script/compiler/manifest.d.ts +3 -0
- package/script/compiler/manifest.d.ts.map +1 -1
- package/script/compiler/manifest.js +10 -3
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +15 -6
- package/script/config/markspec.d.ts +38 -1
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +129 -3
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +143 -147
- package/script/decl/duplicates.d.ts +29 -0
- package/script/decl/duplicates.d.ts.map +1 -0
- package/script/decl/duplicates.js +31 -0
- package/script/decl/mod.d.ts +4 -2
- package/script/decl/mod.d.ts.map +1 -1
- package/script/decl/mod.js +4 -2
- package/script/decl/surfaces.d.ts +29 -7
- package/script/decl/surfaces.d.ts.map +1 -1
- package/script/decl/surfaces.js +32 -19
- package/script/gates/mod.d.ts +13 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +37 -10
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +3 -1
- package/script/lock/acquire_compile.d.ts +31 -0
- package/script/lock/acquire_compile.d.ts.map +1 -0
- package/script/lock/acquire_compile.js +86 -0
- package/script/lock/cache_check.d.ts +28 -0
- package/script/lock/cache_check.d.ts.map +1 -0
- package/script/lock/cache_check.js +54 -0
- package/script/lock/check.d.ts +14 -3
- package/script/lock/check.d.ts.map +1 -1
- package/script/lock/check.js +41 -3
- package/script/lock/git_intent.d.ts +46 -0
- package/script/lock/git_intent.d.ts.map +1 -0
- package/script/lock/git_intent.js +115 -0
- package/script/lock/mod.d.ts +10 -3
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +16 -2
- package/script/lock/model.d.ts +24 -1
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +32 -0
- package/script/lock/pin_assurance.d.ts +20 -0
- package/script/lock/pin_assurance.d.ts.map +1 -0
- package/script/lock/pin_assurance.js +37 -0
- package/script/lock/resolve.d.ts +8 -17
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +7 -68
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +23 -0
- package/script/lock/upstream_common.d.ts +29 -0
- package/script/lock/upstream_common.d.ts.map +1 -0
- package/script/lock/upstream_common.js +42 -0
- package/script/lock/upstream_deps.d.ts +63 -0
- package/script/lock/upstream_deps.d.ts.map +1 -0
- package/script/lock/upstream_deps.js +175 -0
- package/script/lock/upstream_refs.d.ts +69 -0
- package/script/lock/upstream_refs.d.ts.map +1 -0
- package/script/lock/upstream_refs.js +244 -0
- package/script/mod.d.ts +16 -8
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +40 -7
- package/script/model/mod.d.ts +93 -28
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +70 -14
- package/script/model/profile.d.ts +13 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +6 -50
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +20 -3
- package/script/profile/merge.js +7 -0
- package/script/reporter/mod.d.ts +11 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +18 -7
- package/script/typl/assemble.d.ts +53 -0
- package/script/typl/assemble.d.ts.map +1 -0
- package/script/typl/assemble.js +241 -0
- package/script/typl/ast.d.ts +7 -1
- package/script/typl/ast.d.ts.map +1 -1
- package/script/typl/ast.js +3 -0
- package/script/typl/bullet.d.ts +9 -7
- package/script/typl/bullet.d.ts.map +1 -1
- package/script/typl/bullet.js +6 -4
- package/script/typl/citations.d.ts +27 -0
- package/script/typl/citations.d.ts.map +1 -0
- package/script/typl/citations.js +20 -0
- package/script/typl/diagnostics.d.ts +2 -2
- package/script/typl/diagnostics.d.ts.map +1 -1
- package/script/typl/diagnostics.js +18 -0
- package/script/typl/grammar.d.ts.map +1 -1
- package/script/typl/grammar.js +6 -0
- package/script/typl/lexer.d.ts.map +1 -1
- package/script/typl/lexer.js +25 -4
- package/script/typl/mod.d.ts +8 -2
- package/script/typl/mod.d.ts.map +1 -1
- package/script/typl/mod.js +14 -2
- package/script/typl/recognize.js +2 -2
- package/script/typl/registry.d.ts +1 -1
- package/script/typl/resolve.d.ts +31 -0
- package/script/typl/resolve.d.ts.map +1 -0
- package/script/typl/resolve.js +33 -0
- package/script/typl/table.d.ts +52 -0
- package/script/typl/table.d.ts.map +1 -0
- package/script/typl/table.js +75 -0
- package/script/typl/validator.d.ts +24 -5
- package/script/typl/validator.d.ts.map +1 -1
- package/script/typl/validator.js +55 -75
- package/script/upstream/mod.d.ts +45 -0
- package/script/upstream/mod.d.ts.map +1 -0
- package/script/upstream/mod.js +101 -0
- package/script/upstream/project.d.ts +33 -0
- package/script/upstream/project.d.ts.map +1 -0
- package/script/upstream/project.js +41 -0
- package/script/upstream/refs.d.ts +23 -0
- package/script/upstream/refs.d.ts.map +1 -0
- package/script/upstream/refs.js +74 -0
- package/script/util/paths.d.ts +14 -0
- package/script/util/paths.d.ts.map +1 -0
- package/script/util/paths.js +25 -0
- package/script/uxil/assemble.d.ts +38 -0
- package/script/uxil/assemble.d.ts.map +1 -0
- package/script/uxil/assemble.js +272 -0
- package/script/uxil/ast.d.ts +63 -0
- package/script/uxil/ast.d.ts.map +1 -0
- package/script/uxil/ast.js +10 -0
- package/script/uxil/citations.d.ts +27 -0
- package/script/uxil/citations.d.ts.map +1 -0
- package/script/uxil/citations.js +29 -0
- package/script/uxil/diagnostics.d.ts +39 -0
- package/script/uxil/diagnostics.d.ts.map +1 -0
- package/script/uxil/diagnostics.js +140 -0
- package/script/uxil/grammar.d.ts +72 -0
- package/script/uxil/grammar.d.ts.map +1 -0
- package/script/uxil/grammar.js +511 -0
- package/script/uxil/lexer.d.ts +23 -0
- package/script/uxil/lexer.d.ts.map +1 -0
- package/script/uxil/lexer.js +61 -0
- package/script/uxil/mod.d.ts +32 -0
- package/script/uxil/mod.d.ts.map +1 -0
- package/script/uxil/mod.js +37 -0
- package/script/uxil/projection.d.ts +40 -0
- package/script/uxil/projection.d.ts.map +1 -0
- package/script/uxil/projection.js +44 -0
- package/script/uxil/recognize.d.ts +16 -0
- package/script/uxil/recognize.d.ts.map +1 -0
- package/script/uxil/recognize.js +31 -0
- package/script/uxil/registry.d.ts +37 -0
- package/script/uxil/registry.d.ts.map +1 -0
- package/script/uxil/registry.js +32 -0
- package/script/uxil/surfaces.d.ts +36 -0
- package/script/uxil/surfaces.d.ts.map +1 -0
- package/script/uxil/surfaces.js +39 -0
- package/script/uxil/validator.d.ts +36 -0
- package/script/uxil/validator.d.ts.map +1 -0
- package/script/uxil/validator.js +142 -0
- package/script/uxil/vocab.d.ts +33 -0
- package/script/uxil/vocab.d.ts.map +1 -0
- package/script/uxil/vocab.js +41 -0
- package/script/validator/caption_convention.d.ts +2 -1
- package/script/validator/caption_convention.d.ts.map +1 -1
- package/script/validator/caption_convention.js +2 -1
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +39 -16
- package/script/validator/discipline.d.ts +6 -4
- package/script/validator/discipline.d.ts.map +1 -1
- package/script/validator/discipline.js +6 -4
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +27 -14
- package/script/validator/pipeline.d.ts +11 -1
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +67 -17
- package/script/validator/trace_types.d.ts +9 -2
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +20 -4
- package/script/validator/traceability.d.ts +15 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +38 -3
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +10 -0
- package/script/validator/uxil_family.d.ts +43 -0
- package/script/validator/uxil_family.d.ts.map +1 -0
- package/script/validator/uxil_family.js +56 -0
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* [spec §7.6](../../../../docs/superpowers/specs/2026-04-21-adr-008-profile-system-v1-design.md).
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ALLOWED_MARKSPEC_YAML_KEYS = exports.MARKSPEC_YAML_FILENAME = void 0;
|
|
12
|
+
exports.DEFAULT_TOOL_CONFIG = exports.ALLOWED_MARKSPEC_YAML_KEYS = exports.MARKSPEC_YAML_FILENAME = void 0;
|
|
13
13
|
exports.readMarkspecYaml = readMarkspecYaml;
|
|
14
14
|
exports.discoverMarkspecRoot = discoverMarkspecRoot;
|
|
15
15
|
exports.parseMarkspecYaml = parseMarkspecYaml;
|
|
16
16
|
exports.addProfileSpecifier = addProfileSpecifier;
|
|
17
|
+
exports.loadToolConfig = loadToolConfig;
|
|
17
18
|
const yaml_1 = require("@std/yaml");
|
|
18
19
|
const path_1 = require("@std/path");
|
|
19
20
|
/** The consumer-binding config filename, placed next to `project.yaml`. */
|
|
@@ -63,6 +64,17 @@ exports.ALLOWED_MARKSPEC_YAML_KEYS = new Set([
|
|
|
63
64
|
"$schema",
|
|
64
65
|
"profiles",
|
|
65
66
|
"default-profile",
|
|
67
|
+
"exclude",
|
|
68
|
+
"caption-conventions",
|
|
69
|
+
]);
|
|
70
|
+
/** Valid `caption-conventions` keywords (spec §4.7 MSL-C072). */
|
|
71
|
+
const VALID_CAPTION_KEYWORDS = new Set([
|
|
72
|
+
"Figure",
|
|
73
|
+
"Table",
|
|
74
|
+
"Listing",
|
|
75
|
+
"Feature",
|
|
76
|
+
"Equation",
|
|
77
|
+
"List",
|
|
66
78
|
]);
|
|
67
79
|
/**
|
|
68
80
|
* Parse and validate a `.markspec.yaml` string.
|
|
@@ -76,7 +88,10 @@ function parseMarkspecYaml(rawYaml, sourcePath) {
|
|
|
76
88
|
// Empty file is equivalent to `profiles: []`
|
|
77
89
|
const trimmed = rawYaml.trim();
|
|
78
90
|
if (trimmed.length === 0) {
|
|
79
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
config: { profiles: [], exclude: [], captionConventions: {} },
|
|
93
|
+
diagnostics,
|
|
94
|
+
};
|
|
80
95
|
}
|
|
81
96
|
let parsed;
|
|
82
97
|
try {
|
|
@@ -146,12 +161,91 @@ function parseMarkspecYaml(rawYaml, sourcePath) {
|
|
|
146
161
|
}
|
|
147
162
|
defaultProfile = rawDefaultProfile;
|
|
148
163
|
}
|
|
164
|
+
// exclude: optional string[] of gitignore-syntax patterns.
|
|
165
|
+
let exclude = [];
|
|
166
|
+
const rawExclude = root.exclude;
|
|
167
|
+
if (rawExclude !== undefined && rawExclude !== null) {
|
|
168
|
+
if (!Array.isArray(rawExclude)) {
|
|
169
|
+
diagnostics.push({
|
|
170
|
+
code: "MARKSPEC-YAML-003",
|
|
171
|
+
severity: "error",
|
|
172
|
+
message: `.markspec.yaml: 'exclude' expected array, got ${typeof rawExclude}`,
|
|
173
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const bad = rawExclude.findIndex((v) => typeof v !== "string" || v === "");
|
|
178
|
+
if (bad !== -1) {
|
|
179
|
+
diagnostics.push({
|
|
180
|
+
code: "MARKSPEC-YAML-003",
|
|
181
|
+
severity: "error",
|
|
182
|
+
message: `.markspec.yaml: 'exclude[${bad}]': each exclude pattern must be a non-empty string`,
|
|
183
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
exclude = rawExclude;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// caption-conventions: optional mapping of keyword → "above" | "below".
|
|
192
|
+
let captionConventions = {};
|
|
193
|
+
const rawCaptionConventions = root["caption-conventions"];
|
|
194
|
+
if (rawCaptionConventions !== undefined && rawCaptionConventions !== null) {
|
|
195
|
+
if (typeof rawCaptionConventions !== "object" ||
|
|
196
|
+
Array.isArray(rawCaptionConventions)) {
|
|
197
|
+
diagnostics.push({
|
|
198
|
+
code: "MARKSPEC-YAML-003",
|
|
199
|
+
severity: "error",
|
|
200
|
+
message: `.markspec.yaml: 'caption-conventions' expected a mapping of caption-keyword: above|below, got ${Array.isArray(rawCaptionConventions)
|
|
201
|
+
? "array"
|
|
202
|
+
: typeof rawCaptionConventions}`,
|
|
203
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const rawMap = rawCaptionConventions;
|
|
208
|
+
const parsedConventions = {};
|
|
209
|
+
let badKey;
|
|
210
|
+
const captionErrsBefore = diagnostics.length;
|
|
211
|
+
for (const [kw, pos] of Object.entries(rawMap)) {
|
|
212
|
+
if (!VALID_CAPTION_KEYWORDS.has(kw)) {
|
|
213
|
+
badKey = kw;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
if (pos !== "above" && pos !== "below") {
|
|
217
|
+
diagnostics.push({
|
|
218
|
+
code: "MARKSPEC-YAML-003",
|
|
219
|
+
severity: "error",
|
|
220
|
+
message: `.markspec.yaml: 'caption-conventions.${kw}' expected "above" or "below", got ${JSON.stringify(pos)}`,
|
|
221
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
222
|
+
});
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
parsedConventions[kw] = pos;
|
|
226
|
+
}
|
|
227
|
+
if (badKey !== undefined) {
|
|
228
|
+
diagnostics.push({
|
|
229
|
+
code: "MARKSPEC-YAML-003",
|
|
230
|
+
severity: "error",
|
|
231
|
+
message: `.markspec.yaml: 'caption-conventions.${badKey}': unknown caption keyword '${badKey}'; valid keywords: ${[...VALID_CAPTION_KEYWORDS].join(", ")}`,
|
|
232
|
+
location: { file: sourcePath, line: 1, column: 1 },
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (diagnostics.length === captionErrsBefore) {
|
|
236
|
+
captionConventions = parsedConventions;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
149
240
|
// If any specifier failed to parse, treat the whole file as invalid.
|
|
150
241
|
const hasErrors = diagnostics.some((d) => d.severity === "error");
|
|
151
242
|
if (hasErrors) {
|
|
152
243
|
return { config: null, diagnostics };
|
|
153
244
|
}
|
|
154
|
-
return {
|
|
245
|
+
return {
|
|
246
|
+
config: { profiles, defaultProfile, exclude, captionConventions },
|
|
247
|
+
diagnostics,
|
|
248
|
+
};
|
|
155
249
|
}
|
|
156
250
|
/**
|
|
157
251
|
* Parse a single specifier string into a {@linkcode ProfileSpecifier}.
|
|
@@ -269,3 +363,35 @@ async function addProfileSpecifier(specifier, readFileFn, writeFileFn, projectRo
|
|
|
269
363
|
}
|
|
270
364
|
await writeFileFn(filePath, lines.join("\n"));
|
|
271
365
|
}
|
|
366
|
+
/** Defaults used when `.markspec.yaml` is absent or carries neither key. */
|
|
367
|
+
exports.DEFAULT_TOOL_CONFIG = {
|
|
368
|
+
exclude: [],
|
|
369
|
+
captionConventions: {},
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Load the markspec tool config (`exclude`, `caption-conventions`) from
|
|
373
|
+
* `.markspec.yaml` at `projectRoot`.
|
|
374
|
+
*
|
|
375
|
+
* An absent file, or one that parses to a `null` config (a schema or YAML
|
|
376
|
+
* error — see {@linkcode parseMarkspecYaml}), yields
|
|
377
|
+
* {@linkcode DEFAULT_TOOL_CONFIG}; callers inspect the returned
|
|
378
|
+
* diagnostics to decide whether that default is acceptable or fatal.
|
|
379
|
+
*/
|
|
380
|
+
async function loadToolConfig(projectRoot, readFile) {
|
|
381
|
+
const rawYaml = await readMarkspecYaml(projectRoot, readFile);
|
|
382
|
+
if (rawYaml === null) {
|
|
383
|
+
return { config: exports.DEFAULT_TOOL_CONFIG, diagnostics: [] };
|
|
384
|
+
}
|
|
385
|
+
const sourcePath = (0, path_1.join)(projectRoot, exports.MARKSPEC_YAML_FILENAME);
|
|
386
|
+
const { config, diagnostics } = parseMarkspecYaml(rawYaml, sourcePath);
|
|
387
|
+
if (config === null) {
|
|
388
|
+
return { config: exports.DEFAULT_TOOL_CONFIG, diagnostics };
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
config: {
|
|
392
|
+
exclude: config.exclude,
|
|
393
|
+
captionConventions: config.captionConventions,
|
|
394
|
+
},
|
|
395
|
+
diagnostics,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/config/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,iBAAiB,CAAC;AAEzB,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,yFAAyF;AACzF,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAMrE;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AA8DD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,aAAa,CAkHf;AAoGD;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAUvC"}
|
package/script/config/mod.js
CHANGED
|
@@ -53,6 +53,42 @@ function findLineNumber(rawYaml, fieldName) {
|
|
|
53
53
|
return undefined;
|
|
54
54
|
return rawYaml.slice(0, match.index).split("\n").length;
|
|
55
55
|
}
|
|
56
|
+
/** `name:` must be lowercase, start with a letter, and contain only
|
|
57
|
+
* letters, digits, `.`, and `-` (org project schema). */
|
|
58
|
+
const NAME_PATTERN = /^[a-z][a-z0-9.-]*$/;
|
|
59
|
+
/**
|
|
60
|
+
* Org keys `project.yaml` accepts but never parses or acts on — free-form
|
|
61
|
+
* classification/metadata fields owned by the org schema, not MarkSpec.
|
|
62
|
+
*/
|
|
63
|
+
const ORG_INERT_KEYS = new Set([
|
|
64
|
+
"$schema",
|
|
65
|
+
"category",
|
|
66
|
+
"description",
|
|
67
|
+
"license",
|
|
68
|
+
"keywords",
|
|
69
|
+
"labels",
|
|
70
|
+
"authors",
|
|
71
|
+
"homepage",
|
|
72
|
+
"bugs",
|
|
73
|
+
"repository",
|
|
74
|
+
"upstream",
|
|
75
|
+
"process",
|
|
76
|
+
"classification",
|
|
77
|
+
"metadata",
|
|
78
|
+
]);
|
|
79
|
+
/** Keys `parseProjectConfig` actually parses into `ProjectConfig`. */
|
|
80
|
+
const PARSED_KEYS = new Set(["name", "version", "dependencies", "references"]);
|
|
81
|
+
/**
|
|
82
|
+
* Keys retired or relocated by the Task 8 closed-schema flip. Present only
|
|
83
|
+
* to produce an actionable migration message; the key itself is never
|
|
84
|
+
* accepted.
|
|
85
|
+
*/
|
|
86
|
+
const MIGRATED_KEY_HINTS = {
|
|
87
|
+
"exclude": "has moved to .markspec.yaml (markspec tool config)",
|
|
88
|
+
"caption-conventions": "has moved to .markspec.yaml (markspec tool config)",
|
|
89
|
+
"parents": "is retired — declare a 'references:' projectRef instead",
|
|
90
|
+
"parent-fallback": "is retired — declare a 'references:' projectRef instead",
|
|
91
|
+
};
|
|
56
92
|
/**
|
|
57
93
|
* Parse a YAML string and validate it as a MarkSpec project configuration.
|
|
58
94
|
*
|
|
@@ -89,7 +125,7 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
89
125
|
}
|
|
90
126
|
const obj = raw;
|
|
91
127
|
const errors = [];
|
|
92
|
-
// name: required string
|
|
128
|
+
// name: required string, matching the org name pattern
|
|
93
129
|
if (obj.name === undefined || obj.name === null || obj.name === "") {
|
|
94
130
|
errors.push({
|
|
95
131
|
field: "name",
|
|
@@ -104,10 +140,16 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
104
140
|
line: findLineNumber(yaml, "name"),
|
|
105
141
|
});
|
|
106
142
|
}
|
|
107
|
-
|
|
108
|
-
|
|
143
|
+
else if (!NAME_PATTERN.test(obj.name)) {
|
|
144
|
+
errors.push({
|
|
145
|
+
field: "name",
|
|
146
|
+
message: "must match ^[a-z][a-z0-9.-]*$ (lowercase letters, digits, '.', '-'; starts with a letter)",
|
|
147
|
+
line: findLineNumber(yaml, "name"),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// version: required string (org project schema)
|
|
109
151
|
let version = mod_js_1.DEFAULT_PROJECT_CONFIG.version;
|
|
110
|
-
if (obj.version !== undefined && obj.version !== null) {
|
|
152
|
+
if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
|
|
111
153
|
if (typeof obj.version === "number") {
|
|
112
154
|
console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
|
|
113
155
|
`coerced to "${String(obj.version)}". ` +
|
|
@@ -115,159 +157,125 @@ function parseProjectConfig(yaml, filePath) {
|
|
|
115
157
|
}
|
|
116
158
|
version = String(obj.version);
|
|
117
159
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
message: `expected array, got ${typeof obj.labels}`,
|
|
125
|
-
line: findLineNumber(yaml, "labels"),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
const bad = obj.labels.findIndex((v) => typeof v !== "string" || v === "");
|
|
130
|
-
if (bad !== -1) {
|
|
131
|
-
errors.push({
|
|
132
|
-
field: `labels[${bad}]`,
|
|
133
|
-
message: "each label must be a non-empty string",
|
|
134
|
-
line: findLineNumber(yaml, "labels"),
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
labels = obj.labels;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
160
|
+
else {
|
|
161
|
+
errors.push({
|
|
162
|
+
field: "version",
|
|
163
|
+
message: "version is required (org project schema)",
|
|
164
|
+
line: undefined,
|
|
165
|
+
});
|
|
141
166
|
}
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
167
|
+
// dependencies / references: optional projectRef[] (org project-manifest)
|
|
168
|
+
const dependencies = parseProjectRefList(obj["dependencies"], "dependencies", yaml, errors);
|
|
169
|
+
const references = parseProjectRefList(obj["references"], "references", yaml, errors);
|
|
170
|
+
// Closed-schema key classifier: every key must be one this parser reads
|
|
171
|
+
// (PARSED_KEYS), an org-owned free-form field MarkSpec ignores
|
|
172
|
+
// (ORG_INERT_KEYS), or a migrated/retired key with an actionable hint
|
|
173
|
+
// (MIGRATED_KEY_HINTS). Anything else is unknown to the closed schema.
|
|
174
|
+
for (const key of Object.keys(obj)) {
|
|
175
|
+
if (PARSED_KEYS.has(key) || ORG_INERT_KEYS.has(key))
|
|
176
|
+
continue;
|
|
177
|
+
const hint = MIGRATED_KEY_HINTS[key];
|
|
178
|
+
errors.push({
|
|
179
|
+
field: key,
|
|
180
|
+
message: hint !== undefined
|
|
181
|
+
? `'${key}' ${hint}`
|
|
182
|
+
: `unknown key '${key}' (project.yaml follows the closed org schema ` +
|
|
183
|
+
`https://driftsys.github.io/schemas/project/v1.json)`,
|
|
184
|
+
line: findLineNumber(yaml, key),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (errors.length > 0) {
|
|
188
|
+
throw new mod_js_1.ConfigError(filePath, errors);
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
name: obj.name,
|
|
192
|
+
version,
|
|
193
|
+
dependencies,
|
|
194
|
+
references,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// projectRef parsing (org project-manifest contract: dependencies/references)
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
/** Safe upstream id: single path segment, no separators or traversal. */
|
|
201
|
+
const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
202
|
+
const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
|
|
203
|
+
/**
|
|
204
|
+
* Parse a `dependencies:` or `references:` list of projectRef objects
|
|
205
|
+
* (`{ url (required), version?, name? }`). Pushes field errors onto
|
|
206
|
+
* `errors` and returns whatever refs parsed cleanly; the caller throws
|
|
207
|
+
* once all fields have been checked, so a single invalid entry doesn't
|
|
208
|
+
* mask other unrelated errors.
|
|
209
|
+
*/
|
|
210
|
+
function parseProjectRefList(value, field, yaml, errors) {
|
|
211
|
+
if (value === undefined || value === null)
|
|
212
|
+
return [];
|
|
213
|
+
if (!Array.isArray(value)) {
|
|
214
|
+
errors.push({
|
|
215
|
+
field,
|
|
216
|
+
message: "must be a list of projectRef objects ({ url, version?, name? })",
|
|
217
|
+
line: findLineNumber(yaml, field),
|
|
218
|
+
});
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
const out = [];
|
|
222
|
+
value.forEach((item, i) => {
|
|
223
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
146
224
|
errors.push({
|
|
147
|
-
field:
|
|
148
|
-
message:
|
|
149
|
-
line: findLineNumber(yaml,
|
|
225
|
+
field: `${field}[${i}]`,
|
|
226
|
+
message: "must be a mapping with a required 'url' key",
|
|
227
|
+
line: findLineNumber(yaml, field),
|
|
150
228
|
});
|
|
229
|
+
return;
|
|
151
230
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
231
|
+
const record = item;
|
|
232
|
+
for (const key of Object.keys(record)) {
|
|
233
|
+
if (!PROJECT_REF_KEYS.has(key)) {
|
|
155
234
|
errors.push({
|
|
156
|
-
field:
|
|
157
|
-
message:
|
|
158
|
-
line: findLineNumber(yaml,
|
|
235
|
+
field: `${field}[${i}]`,
|
|
236
|
+
message: `unknown projectRef key '${key}' (allowed: url, version, name)`,
|
|
237
|
+
line: findLineNumber(yaml, key),
|
|
159
238
|
});
|
|
160
239
|
}
|
|
161
|
-
else {
|
|
162
|
-
parents = obj.parents;
|
|
163
|
-
}
|
|
164
240
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
let parentFallback = mod_js_1.DEFAULT_PROJECT_CONFIG.parentFallback;
|
|
168
|
-
const fallbackKey = "parent-fallback";
|
|
169
|
-
if (obj[fallbackKey] !== undefined && obj[fallbackKey] !== null) {
|
|
170
|
-
const val = obj[fallbackKey];
|
|
171
|
-
if (typeof val !== "string" || !isValidUrl(val)) {
|
|
241
|
+
const url = record.url;
|
|
242
|
+
if (typeof url !== "string" || url.length === 0) {
|
|
172
243
|
errors.push({
|
|
173
|
-
field:
|
|
174
|
-
message: "
|
|
175
|
-
line: findLineNumber(yaml,
|
|
244
|
+
field: `${field}[${i}].url`,
|
|
245
|
+
message: "projectRef requires a non-empty 'url' string",
|
|
246
|
+
line: findLineNumber(yaml, field),
|
|
176
247
|
});
|
|
248
|
+
return;
|
|
177
249
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
// caption-conventions: optional mapping of keyword → "above" | "below"
|
|
183
|
-
let captionConventions = mod_js_1.DEFAULT_PROJECT_CONFIG.captionConventions;
|
|
184
|
-
const captionConventionsKey = "caption-conventions";
|
|
185
|
-
if (obj[captionConventionsKey] !== undefined &&
|
|
186
|
-
obj[captionConventionsKey] !== null) {
|
|
187
|
-
const raw = obj[captionConventionsKey];
|
|
188
|
-
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
189
|
-
errors.push({
|
|
190
|
-
field: captionConventionsKey,
|
|
191
|
-
message: `expected a mapping of caption-keyword: above|below, got ${Array.isArray(raw) ? "array" : typeof raw}`,
|
|
192
|
-
line: findLineNumber(yaml, captionConventionsKey),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
const rawMap = raw;
|
|
197
|
-
const VALID_KEYWORDS = new Set([
|
|
198
|
-
"Figure",
|
|
199
|
-
"Table",
|
|
200
|
-
"Listing",
|
|
201
|
-
"Feature",
|
|
202
|
-
"Equation",
|
|
203
|
-
"List",
|
|
204
|
-
]);
|
|
205
|
-
const parsed = {};
|
|
206
|
-
let badKey;
|
|
207
|
-
const captionErrsBefore = errors.length;
|
|
208
|
-
for (const [kw, pos] of Object.entries(rawMap)) {
|
|
209
|
-
if (!VALID_KEYWORDS.has(kw)) {
|
|
210
|
-
badKey = kw;
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
if (pos !== "above" && pos !== "below") {
|
|
214
|
-
errors.push({
|
|
215
|
-
field: `${captionConventionsKey}.${kw}`,
|
|
216
|
-
message: `expected "above" or "below", got ${JSON.stringify(pos)}`,
|
|
217
|
-
line: findLineNumber(yaml, captionConventionsKey),
|
|
218
|
-
});
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
parsed[kw] = pos;
|
|
222
|
-
}
|
|
223
|
-
if (badKey !== undefined) {
|
|
250
|
+
const ref = { url };
|
|
251
|
+
if (record.version !== undefined) {
|
|
252
|
+
if (typeof record.version !== "string" || record.version.length === 0) {
|
|
224
253
|
errors.push({
|
|
225
|
-
field: `${
|
|
226
|
-
message:
|
|
227
|
-
line: findLineNumber(yaml,
|
|
254
|
+
field: `${field}[${i}].version`,
|
|
255
|
+
message: "must be a non-empty string when present",
|
|
256
|
+
line: findLineNumber(yaml, field),
|
|
228
257
|
});
|
|
229
258
|
}
|
|
230
|
-
|
|
231
|
-
|
|
259
|
+
else {
|
|
260
|
+
ref.version = record.version;
|
|
232
261
|
}
|
|
233
262
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (obj.exclude !== undefined && obj.exclude !== null) {
|
|
238
|
-
if (!Array.isArray(obj.exclude)) {
|
|
239
|
-
errors.push({
|
|
240
|
-
field: "exclude",
|
|
241
|
-
message: `expected array, got ${typeof obj.exclude}`,
|
|
242
|
-
line: findLineNumber(yaml, "exclude"),
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
const bad = obj.exclude.findIndex((v) => typeof v !== "string" || v === "");
|
|
247
|
-
if (bad !== -1) {
|
|
263
|
+
if (record.name !== undefined) {
|
|
264
|
+
if (typeof record.name !== "string" ||
|
|
265
|
+
!PROJECT_REF_NAME_RE.test(record.name)) {
|
|
248
266
|
errors.push({
|
|
249
|
-
field:
|
|
250
|
-
message: "
|
|
251
|
-
line: findLineNumber(yaml,
|
|
267
|
+
field: `${field}[${i}].name`,
|
|
268
|
+
message: "must match [A-Za-z0-9][A-Za-z0-9._-]* (used as a cache directory name)",
|
|
269
|
+
line: findLineNumber(yaml, field),
|
|
252
270
|
});
|
|
253
271
|
}
|
|
254
272
|
else {
|
|
255
|
-
|
|
273
|
+
ref.name = record.name;
|
|
256
274
|
}
|
|
257
275
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
return {
|
|
263
|
-
name: obj.name,
|
|
264
|
-
version,
|
|
265
|
-
labels,
|
|
266
|
-
parents,
|
|
267
|
-
parentFallback,
|
|
268
|
-
captionConventions,
|
|
269
|
-
exclude,
|
|
270
|
-
};
|
|
276
|
+
out.push(ref);
|
|
277
|
+
});
|
|
278
|
+
return out;
|
|
271
279
|
}
|
|
272
280
|
// ---------------------------------------------------------------------------
|
|
273
281
|
// Domain derivation
|
|
@@ -315,15 +323,3 @@ async function loadConfig(startDir, readFile) {
|
|
|
315
323
|
const config = parseProjectConfig(content, configPath);
|
|
316
324
|
return { config, projectRoot: root, configPath };
|
|
317
325
|
}
|
|
318
|
-
// ---------------------------------------------------------------------------
|
|
319
|
-
// Helpers
|
|
320
|
-
// ---------------------------------------------------------------------------
|
|
321
|
-
function isValidUrl(value) {
|
|
322
|
-
try {
|
|
323
|
-
new URL(value);
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
catch {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/decl/duplicates
|
|
3
|
+
*
|
|
4
|
+
* DSL-agnostic "declared exactly once" scan over a corpus-wide registry
|
|
5
|
+
* (uxil epic #717 §A, #754). Both typl's dotted-name bindings (TYPL-009)
|
|
6
|
+
* and uxil's own registry (#726) need the identical shape: a
|
|
7
|
+
* `Map<name, T[]>` where any name with more than one declaration is a
|
|
8
|
+
* violation. The engine only counts and groups — the DSL host supplies
|
|
9
|
+
* the registry, narrows which names to check via `predicate`, and maps
|
|
10
|
+
* each {@linkcode DuplicateDeclaration} to its own diagnostic code.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* One corpus-wide multiple-declaration violation: `name` was declared
|
|
14
|
+
* more than once. `first` is the earliest declaration (registry
|
|
15
|
+
* insertion order); `duplicates` are the rest, in the same order.
|
|
16
|
+
*/
|
|
17
|
+
export interface DuplicateDeclaration<T> {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly first: T;
|
|
20
|
+
readonly duplicates: readonly T[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scan `registry` for names declared more than once. Returns one entry
|
|
24
|
+
* per offending name, in `registry`'s iteration order. `predicate`
|
|
25
|
+
* narrows which names are checked at all (e.g. typl's "only dotted,
|
|
26
|
+
* published names" rule); defaults to checking every name.
|
|
27
|
+
*/
|
|
28
|
+
export declare function findDuplicateDeclarations<T>(registry: ReadonlyMap<string, readonly T[]>, predicate?: (name: string) => boolean): readonly DuplicateDeclaration<T>[];
|
|
29
|
+
//# sourceMappingURL=duplicates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicates.d.ts","sourceRoot":"","sources":["../../src/decl/duplicates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,EAC3C,SAAS,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAoB,GAChD,SAAS,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAQpC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/decl/duplicates
|
|
4
|
+
*
|
|
5
|
+
* DSL-agnostic "declared exactly once" scan over a corpus-wide registry
|
|
6
|
+
* (uxil epic #717 §A, #754). Both typl's dotted-name bindings (TYPL-009)
|
|
7
|
+
* and uxil's own registry (#726) need the identical shape: a
|
|
8
|
+
* `Map<name, T[]>` where any name with more than one declaration is a
|
|
9
|
+
* violation. The engine only counts and groups — the DSL host supplies
|
|
10
|
+
* the registry, narrows which names to check via `predicate`, and maps
|
|
11
|
+
* each {@linkcode DuplicateDeclaration} to its own diagnostic code.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.findDuplicateDeclarations = findDuplicateDeclarations;
|
|
15
|
+
/**
|
|
16
|
+
* Scan `registry` for names declared more than once. Returns one entry
|
|
17
|
+
* per offending name, in `registry`'s iteration order. `predicate`
|
|
18
|
+
* narrows which names are checked at all (e.g. typl's "only dotted,
|
|
19
|
+
* published names" rule); defaults to checking every name.
|
|
20
|
+
*/
|
|
21
|
+
function findDuplicateDeclarations(registry, predicate = () => true) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const [name, decls] of registry) {
|
|
24
|
+
if (decls.length < 2)
|
|
25
|
+
continue;
|
|
26
|
+
if (!predicate(name))
|
|
27
|
+
continue;
|
|
28
|
+
out.push({ name, first: decls[0], duplicates: decls.slice(1) });
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
package/script/decl/mod.d.ts
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* against the base an enclosing declaration establishes. typl consumes
|
|
10
10
|
* these today; uxil (§B) rides on the same substrate.
|
|
11
11
|
*/
|
|
12
|
-
export type { BlockDeclaration, FenceRecognizer, InlineDeclaration, TextRecognizer, } from "./surfaces.js";
|
|
13
|
-
export {
|
|
12
|
+
export type { BlockDeclaration, FenceRecognizer, InlineDeclaration, NestedBlockDeclaration, TextRecognizer, } from "./surfaces.js";
|
|
13
|
+
export { extractFenceDeclarations, extractInlineDeclarations, extractNestedBulletDeclarations, stripCodeSpanDelimiters, } from "./surfaces.js";
|
|
14
14
|
export type { RowRecognizer, TableRowDeclaration } from "./table.js";
|
|
15
15
|
export { extractTableDeclarations } from "./table.js";
|
|
16
16
|
export type { BaseScope, RefOps, RefResolution, RootCheck } from "./resolve.js";
|
|
17
17
|
export { checkSingleRoot, resolveRef } from "./resolve.js";
|
|
18
|
+
export type { DuplicateDeclaration } from "./duplicates.js";
|
|
19
|
+
export { findDuplicateDeclarations } from "./duplicates.js";
|
|
18
20
|
//# sourceMappingURL=mod.d.ts.map
|
package/script/decl/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/decl/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/decl/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE3D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/script/decl/mod.js
CHANGED
|
@@ -11,14 +11,16 @@
|
|
|
11
11
|
* these today; uxil (§B) rides on the same substrate.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.resolveRef = exports.checkSingleRoot = exports.extractTableDeclarations = exports.stripCodeSpanDelimiters = exports.
|
|
14
|
+
exports.findDuplicateDeclarations = exports.resolveRef = exports.checkSingleRoot = exports.extractTableDeclarations = exports.stripCodeSpanDelimiters = exports.extractNestedBulletDeclarations = exports.extractInlineDeclarations = exports.extractFenceDeclarations = void 0;
|
|
15
15
|
var surfaces_js_1 = require("./surfaces.js");
|
|
16
|
-
Object.defineProperty(exports, "extractBulletDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractBulletDeclarations; } });
|
|
17
16
|
Object.defineProperty(exports, "extractFenceDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractFenceDeclarations; } });
|
|
18
17
|
Object.defineProperty(exports, "extractInlineDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractInlineDeclarations; } });
|
|
18
|
+
Object.defineProperty(exports, "extractNestedBulletDeclarations", { enumerable: true, get: function () { return surfaces_js_1.extractNestedBulletDeclarations; } });
|
|
19
19
|
Object.defineProperty(exports, "stripCodeSpanDelimiters", { enumerable: true, get: function () { return surfaces_js_1.stripCodeSpanDelimiters; } });
|
|
20
20
|
var table_js_1 = require("./table.js");
|
|
21
21
|
Object.defineProperty(exports, "extractTableDeclarations", { enumerable: true, get: function () { return table_js_1.extractTableDeclarations; } });
|
|
22
22
|
var resolve_js_1 = require("./resolve.js");
|
|
23
23
|
Object.defineProperty(exports, "checkSingleRoot", { enumerable: true, get: function () { return resolve_js_1.checkSingleRoot; } });
|
|
24
24
|
Object.defineProperty(exports, "resolveRef", { enumerable: true, get: function () { return resolve_js_1.resolveRef; } });
|
|
25
|
+
var duplicates_js_1 = require("./duplicates.js");
|
|
26
|
+
Object.defineProperty(exports, "findDuplicateDeclarations", { enumerable: true, get: function () { return duplicates_js_1.findDuplicateDeclarations; } });
|