@driftsys/markspec 0.4.0 → 0.5.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/esm/ast/build.d.ts +70 -0
- package/esm/ast/build.d.ts.map +1 -0
- package/esm/ast/build.js +605 -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 +221 -0
- package/esm/ast/nodes.d.ts.map +1 -0
- package/esm/ast/nodes.js +12 -0
- package/esm/ast/normalize.d.ts +67 -0
- package/esm/ast/normalize.d.ts.map +1 -0
- package/esm/ast/normalize.js +255 -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/inverses.d.ts +2 -8
- package/esm/compiler/inverses.d.ts.map +1 -1
- package/esm/compiler/inverses.js +50 -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 +9 -1
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +21 -2
- 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 +18 -1
- package/esm/compiler/schema.d.ts.map +1 -1
- package/esm/compiler/schema.js +18 -9
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +54 -0
- package/esm/formatter/mod.d.ts +49 -4
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +362 -33
- 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/lint/mod.d.ts +10 -0
- package/esm/lint/mod.d.ts.map +1 -0
- package/esm/lint/mod.js +7 -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/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 +19 -0
- package/esm/lint/rules/suppression.d.ts.map +1 -0
- package/esm/lint/rules/suppression.js +75 -0
- package/esm/lint/runner.d.ts +39 -0
- package/esm/lint/runner.d.ts.map +1 -0
- package/esm/lint/runner.js +112 -0
- package/esm/lint/types.d.ts +19 -0
- package/esm/lint/types.d.ts.map +1 -0
- package/esm/lint/types.js +9 -0
- package/esm/mod.d.ts +19 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +14 -3
- package/esm/model/attributes.d.ts.map +1 -1
- package/esm/model/attributes.js +163 -2
- 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 +98 -3
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +57 -2
- package/esm/model/profile.d.ts +33 -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 +9 -6
- package/esm/parser/entity_refs.d.ts +53 -0
- package/esm/parser/entity_refs.d.ts.map +1 -0
- package/esm/parser/entity_refs.js +151 -0
- package/esm/parser/glossary.d.ts +43 -0
- package/esm/parser/glossary.d.ts.map +1 -0
- package/esm/parser/glossary.js +217 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +223 -7
- package/esm/parser/mod.d.ts +1 -0
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +1 -0
- package/esm/parser/source.d.ts +20 -0
- package/esm/parser/source.d.ts.map +1 -1
- package/esm/parser/source.js +3 -3
- package/esm/profile/chain.js +3 -13
- package/esm/profile/colors.js +1 -1
- 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.map +1 -1
- package/esm/profile/load.js +67 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +277 -88
- package/esm/profile/merge.js +139 -39
- package/esm/profile/mod.d.ts +2 -4
- package/esm/profile/mod.d.ts.map +1 -1
- package/esm/profile/mod.js +5 -2
- package/esm/reporter/mod.js +4 -4
- 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/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/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 +2 -0
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +253 -12
- package/esm/validator/modal_keywords.d.ts +23 -0
- package/esm/validator/modal_keywords.d.ts.map +1 -0
- package/esm/validator/modal_keywords.js +137 -0
- 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 +7 -2
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +40 -7
- 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 +140 -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 +1 -1
- package/script/ast/build.d.ts +70 -0
- package/script/ast/build.d.ts.map +1 -0
- package/script/ast/build.js +610 -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 +221 -0
- package/script/ast/nodes.d.ts.map +1 -0
- package/script/ast/nodes.js +13 -0
- package/script/ast/normalize.d.ts +67 -0
- package/script/ast/normalize.d.ts.map +1 -0
- package/script/ast/normalize.js +258 -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/inverses.d.ts +2 -8
- package/script/compiler/inverses.d.ts.map +1 -1
- package/script/compiler/inverses.js +50 -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 +9 -1
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +21 -2
- 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 +18 -1
- package/script/compiler/schema.d.ts.map +1 -1
- package/script/compiler/schema.js +18 -8
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +54 -0
- package/script/formatter/mod.d.ts +49 -4
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +365 -33
- 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/lint/mod.d.ts +10 -0
- package/script/lint/mod.d.ts.map +1 -0
- package/script/lint/mod.js +12 -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/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 +19 -0
- package/script/lint/rules/suppression.d.ts.map +1 -0
- package/script/lint/rules/suppression.js +80 -0
- package/script/lint/runner.d.ts +39 -0
- package/script/lint/runner.d.ts.map +1 -0
- package/script/lint/runner.js +116 -0
- package/script/lint/types.d.ts +19 -0
- package/script/lint/types.d.ts.map +1 -0
- package/script/lint/types.js +10 -0
- package/script/mod.d.ts +19 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +56 -32
- package/script/model/attributes.d.ts.map +1 -1
- package/script/model/attributes.js +163 -2
- 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 +98 -3
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +64 -3
- package/script/model/profile.d.ts +33 -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 +9 -6
- package/script/parser/entity_refs.d.ts +53 -0
- package/script/parser/entity_refs.d.ts.map +1 -0
- package/script/parser/entity_refs.js +155 -0
- package/script/parser/glossary.d.ts +43 -0
- package/script/parser/glossary.d.ts.map +1 -0
- package/script/parser/glossary.js +221 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +222 -6
- package/script/parser/mod.d.ts +1 -0
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +5 -1
- package/script/parser/source.d.ts +20 -0
- package/script/parser/source.d.ts.map +1 -1
- package/script/parser/source.js +3 -0
- package/script/profile/chain.js +3 -13
- package/script/profile/colors.js +1 -1
- 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.map +1 -1
- package/script/profile/load.js +67 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +276 -87
- package/script/profile/merge.js +139 -39
- package/script/profile/mod.d.ts +2 -4
- package/script/profile/mod.d.ts.map +1 -1
- package/script/profile/mod.js +7 -6
- package/script/reporter/mod.js +4 -4
- 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/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/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 +2 -0
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +256 -14
- package/script/validator/modal_keywords.d.ts +23 -0
- package/script/validator/modal_keywords.d.ts.map +1 -0
- package/script/validator/modal_keywords.js +140 -0
- 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 +7 -2
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +39 -6
- 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 +146 -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
|
@@ -9,7 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.parseMarkdown = parseMarkdown;
|
|
10
10
|
const mod_js_1 = require("../model/mod.js");
|
|
11
11
|
const attributes_js_1 = require("./attributes.js");
|
|
12
|
+
const entity_refs_js_1 = require("./entity_refs.js");
|
|
12
13
|
const remark_js_1 = require("./remark.js");
|
|
14
|
+
const build_js_1 = require("../ast/build.js");
|
|
13
15
|
/**
|
|
14
16
|
* Slug pattern for referenced-entry display IDs.
|
|
15
17
|
*
|
|
@@ -20,6 +22,10 @@ const remark_js_1 = require("./remark.js");
|
|
|
20
22
|
const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
|
|
21
23
|
/** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
|
|
22
24
|
const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
25
|
+
/** Match `[]` at the start — empty brackets. */
|
|
26
|
+
const EMPTY_BRACKET_RE = /^\[\]\s*(.*)$/;
|
|
27
|
+
/** Match `[` at the start without a closing `]` on the same logical content — unterminated. */
|
|
28
|
+
const UNTERMINATED_BRACKET_RE = /^\[[^\]]*$/;
|
|
23
29
|
/**
|
|
24
30
|
* Find the `Id:` attribute on an entry. Returns undefined when absent. If
|
|
25
31
|
* more than one `Id:` is present, returns the first — the validator flags
|
|
@@ -108,11 +114,36 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
108
114
|
let title;
|
|
109
115
|
if (firstInline.type === "text") {
|
|
110
116
|
// remark may parse `[ID] Title` as a single text node
|
|
111
|
-
const
|
|
117
|
+
const textValue = firstInline.value;
|
|
118
|
+
const match = ENTRY_START_RE.exec(textValue);
|
|
112
119
|
if (match) {
|
|
113
120
|
displayId = match[1];
|
|
114
121
|
title = match[2].trim();
|
|
115
122
|
}
|
|
123
|
+
else if (EMPTY_BRACKET_RE.test(textValue)) {
|
|
124
|
+
// MSL-P001: bracketed content is empty — `- [] Title`
|
|
125
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
126
|
+
diagnostics.push({
|
|
127
|
+
code: "MSL-P001",
|
|
128
|
+
severity: "error",
|
|
129
|
+
message: "list item starts with `[]` but the bracketed content is empty " +
|
|
130
|
+
"(spec section 4.1)",
|
|
131
|
+
location: { file, line: entryLine, column: 1 },
|
|
132
|
+
});
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
else if (UNTERMINATED_BRACKET_RE.test(textValue)) {
|
|
136
|
+
// MSL-P003: display-ID brackets unterminated (missing `]`)
|
|
137
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
138
|
+
diagnostics.push({
|
|
139
|
+
code: "MSL-P003",
|
|
140
|
+
severity: "error",
|
|
141
|
+
message: "display-ID brackets unterminated -- missing `]` before end of " +
|
|
142
|
+
"title line (spec section 4.1)",
|
|
143
|
+
location: { file, line: entryLine, column: 1 },
|
|
144
|
+
});
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
116
147
|
}
|
|
117
148
|
// Try linkReference pattern: remark sometimes parses [ID] as a linkReference
|
|
118
149
|
if (!displayId && firstInline.type === "linkReference") {
|
|
@@ -143,10 +174,168 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
143
174
|
// citation compatibility. Canonical slug never contains `@`.
|
|
144
175
|
if (displayId.startsWith("@"))
|
|
145
176
|
displayId = displayId.slice(1);
|
|
177
|
+
// MSL-I005: Display ID is empty (after `@` stripping).
|
|
178
|
+
if (displayId.length === 0) {
|
|
179
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
180
|
+
diagnostics.push({
|
|
181
|
+
code: "MSL-I005",
|
|
182
|
+
severity: "error",
|
|
183
|
+
message: "display ID is empty (spec section 4.2)",
|
|
184
|
+
location: { file, line: entryLine, column: 1 },
|
|
185
|
+
});
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
// MSL-P002: title text missing after `]`. The title capture is empty
|
|
189
|
+
// and was not populated from subsequent nodes (linkReference path sets
|
|
190
|
+
// title from rest nodes).
|
|
191
|
+
if (title !== undefined && title.length === 0) {
|
|
192
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
193
|
+
diagnostics.push({
|
|
194
|
+
code: "MSL-P002",
|
|
195
|
+
severity: "error",
|
|
196
|
+
message: `${displayId}: title line missing title text after ']' (spec section 4.1)`,
|
|
197
|
+
location: { file, line: entryLine, column: 1 },
|
|
198
|
+
});
|
|
199
|
+
// Continue parsing — entry is still structurally valid for downstream
|
|
200
|
+
// validation (MSL-P010 also fires from the validator for empty titles).
|
|
201
|
+
}
|
|
146
202
|
// Extract body content and attributes.
|
|
147
203
|
const bodyContent = extractBodyContent(item, markdown);
|
|
148
204
|
const [body, attrLines] = (0, attributes_js_1.splitBodyAndAttributes)(bodyContent);
|
|
149
205
|
const attributes = (0, attributes_js_1.parseAttributes)(attrLines);
|
|
206
|
+
const bodyAst = (0, build_js_1.buildBodyAst)(body);
|
|
207
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
208
|
+
// MSL-P020: trailers block is not the final indented code block.
|
|
209
|
+
// Detect `Key: Value` lines in the body that likely should be trailers
|
|
210
|
+
// but are not at the final position (body content follows them).
|
|
211
|
+
// Exclude caption keywords (Figure:, Table:, etc.) which are legitimate
|
|
212
|
+
// body content, not misplaced trailer attributes.
|
|
213
|
+
const CAPTION_KEYWORDS = new Set([
|
|
214
|
+
"Figure",
|
|
215
|
+
"Table",
|
|
216
|
+
"Listing",
|
|
217
|
+
"Feature",
|
|
218
|
+
"Equation",
|
|
219
|
+
"List",
|
|
220
|
+
]);
|
|
221
|
+
if (body.length > 0) {
|
|
222
|
+
const bodyLines = body.split("\n");
|
|
223
|
+
let inFencedBlock = false;
|
|
224
|
+
for (let i = 0; i < bodyLines.length; i++) {
|
|
225
|
+
const trimmed = bodyLines[i].trim();
|
|
226
|
+
// Track fenced code blocks (``` or ~~~) to skip their contents
|
|
227
|
+
if (/^(`{3,}|~{3,})/.test(trimmed)) {
|
|
228
|
+
inFencedBlock = !inFencedBlock;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (inFencedBlock)
|
|
232
|
+
continue;
|
|
233
|
+
if (!attributes_js_1.ATTR_LINE_RE.test(trimmed))
|
|
234
|
+
continue;
|
|
235
|
+
// Extract the key portion to check against caption keywords
|
|
236
|
+
const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
|
|
237
|
+
if (keyMatch && CAPTION_KEYWORDS.has(keyMatch[1]))
|
|
238
|
+
continue;
|
|
239
|
+
// Found a Key: Value line in the body — non-final position
|
|
240
|
+
diagnostics.push({
|
|
241
|
+
code: "MSL-P020",
|
|
242
|
+
severity: "error",
|
|
243
|
+
message: `${displayId}: trailers block is not the final indented code ` +
|
|
244
|
+
`block of the entry -- content appears after trailer-like ` +
|
|
245
|
+
`lines (spec section 4.1)`,
|
|
246
|
+
location: { file, line: entryLine, column: 1 },
|
|
247
|
+
});
|
|
248
|
+
break; // One diagnostic per entry is sufficient
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
|
|
252
|
+
// The trailer block is the final indented code block. Lines within it
|
|
253
|
+
// should all match `Key: Value` syntax. We check both the parsed
|
|
254
|
+
// attrLines AND the trailing body lines that might be in a code block
|
|
255
|
+
// but failed ATTR_LINE_RE (thus stayed in the body).
|
|
256
|
+
const TRAILER_KEY_RE = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
257
|
+
const COLON_SPLIT_RE = /^([^:]+):\s*(.*)$/;
|
|
258
|
+
// Check lines that DID end up in attrLines but might have key issues
|
|
259
|
+
for (const rawLine of attrLines) {
|
|
260
|
+
const trimmed = rawLine.trim();
|
|
261
|
+
if (!trimmed)
|
|
262
|
+
continue;
|
|
263
|
+
if (!attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
|
|
264
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
265
|
+
if (colonMatch) {
|
|
266
|
+
const key = colonMatch[1].trim();
|
|
267
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
268
|
+
diagnostics.push({
|
|
269
|
+
code: "MSL-P022",
|
|
270
|
+
severity: "error",
|
|
271
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
272
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
273
|
+
location: { file, line: entryLine, column: 1 },
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
diagnostics.push({
|
|
278
|
+
code: "MSL-P021",
|
|
279
|
+
severity: "error",
|
|
280
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
281
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
282
|
+
location: { file, line: entryLine, column: 1 },
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
diagnostics.push({
|
|
288
|
+
code: "MSL-P021",
|
|
289
|
+
severity: "error",
|
|
290
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
291
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
292
|
+
location: { file, line: entryLine, column: 1 },
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Also scan trailing body lines for suspected misplaced trailers.
|
|
298
|
+
// If the body's last non-empty lines look like they belong to an
|
|
299
|
+
// indented code block with colon-separated content that has invalid
|
|
300
|
+
// keys, emit P022. Lines without colons that appear in what looks
|
|
301
|
+
// like a trailer block emit P021.
|
|
302
|
+
if (body.length > 0) {
|
|
303
|
+
const bodyLines = body.split("\n");
|
|
304
|
+
// Walk backward from the end of the body to find lines in a trailing
|
|
305
|
+
// code-block-like region that have colons (suspected trailers).
|
|
306
|
+
for (let i = bodyLines.length - 1; i >= 0; i--) {
|
|
307
|
+
const trimmed = bodyLines[i].trim();
|
|
308
|
+
if (!trimmed)
|
|
309
|
+
continue; // skip trailing blanks
|
|
310
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
311
|
+
if (!colonMatch)
|
|
312
|
+
break; // stop at non-colon line
|
|
313
|
+
const key = colonMatch[1].trim();
|
|
314
|
+
if (attributes_js_1.ATTR_LINE_RE.test(trimmed)) {
|
|
315
|
+
// Valid attr line in body → already caught by P020
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
319
|
+
diagnostics.push({
|
|
320
|
+
code: "MSL-P022",
|
|
321
|
+
severity: "error",
|
|
322
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
323
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
324
|
+
location: { file, line: entryLine, column: 1 },
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
else if (colonMatch[2].trim().length === 0) {
|
|
328
|
+
diagnostics.push({
|
|
329
|
+
code: "MSL-P021",
|
|
330
|
+
severity: "error",
|
|
331
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
332
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
333
|
+
location: { file, line: entryLine, column: 1 },
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
break; // one diagnostic per trailing suspect line is sufficient
|
|
337
|
+
}
|
|
338
|
+
}
|
|
150
339
|
// Detect legacy paragraph + trailing-backslash attribute form and warn.
|
|
151
340
|
if (attributes.length > 0 &&
|
|
152
341
|
attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
|
|
@@ -170,45 +359,72 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
170
359
|
// `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
|
|
171
360
|
// identified entry so the validator can surface MSL-R004; missing
|
|
172
361
|
// shape on a parsed entry is not useful downstream.
|
|
173
|
-
shape = "
|
|
362
|
+
shape = "Authored";
|
|
174
363
|
}
|
|
175
364
|
}
|
|
176
365
|
else {
|
|
177
366
|
// No `Id:`. Fall back on display-ID shape + document context to decide
|
|
178
367
|
// whether to admit the entry at all.
|
|
179
368
|
if (isReferencesDoc && SLUG_RE.test(displayId)) {
|
|
180
|
-
shape = "
|
|
369
|
+
shape = "Reference";
|
|
181
370
|
}
|
|
182
371
|
else {
|
|
183
372
|
// No identity attribute and no references-doc context — admit as
|
|
184
373
|
// identified so the validator can surface the missing-`Id:` error.
|
|
185
|
-
shape = "
|
|
374
|
+
shape = "Authored";
|
|
186
375
|
}
|
|
187
376
|
}
|
|
188
377
|
// Inferred type from display-ID prefix — left to the profile layer. For
|
|
189
378
|
// now the core records no type; downstream profile-aware code populates
|
|
190
379
|
// this field when a profile is loaded.
|
|
191
380
|
const type = undefined;
|
|
381
|
+
// MSL-P030: Authored entry has no body block (title + trailers only).
|
|
382
|
+
// For Reference shape, body is optional (ADR-002 section Part 3). For Authored,
|
|
383
|
+
// the body is required. We also emit P030 when the body is empty (all
|
|
384
|
+
// content was consumed as attributes).
|
|
385
|
+
if (shape === "Authored" && body.trim().length === 0) {
|
|
386
|
+
diagnostics.push({
|
|
387
|
+
code: "MSL-P030",
|
|
388
|
+
severity: "error",
|
|
389
|
+
message: `${displayId}: Authored entry has no body block -- entries must ` +
|
|
390
|
+
`have body content between title and trailers (spec section 4.1)`,
|
|
391
|
+
location: { file, line: entryLine, column: 1 },
|
|
392
|
+
});
|
|
393
|
+
}
|
|
192
394
|
// Body requirement: identified entries require a body; referenced entries
|
|
193
395
|
// may omit it. If there's only one child (the title paragraph), admit
|
|
194
396
|
// only referenced entries.
|
|
195
|
-
if (shape !== "
|
|
397
|
+
if (shape !== "Reference" && item.children.length < 2)
|
|
196
398
|
return undefined;
|
|
197
399
|
// Source location
|
|
198
400
|
const line = item.position?.start.line ?? 1;
|
|
199
401
|
const column = item.position?.start.column ?? 1;
|
|
402
|
+
const entryLocation = { file, line, column };
|
|
403
|
+
// Inline `$Identifier` entity references (spec section 2.5.2). Resolution
|
|
404
|
+
// into the project's entity registry is left to the validator's
|
|
405
|
+
// marker pass; the parser only emits the lexical hits.
|
|
406
|
+
// Pass the already-built bodyAst to avoid a redundant mdast parse.
|
|
407
|
+
const entityRefs = (0, entity_refs_js_1.extractEntityRefs)(body, {
|
|
408
|
+
file,
|
|
409
|
+
// Body content starts on the line after the title; +1 keeps
|
|
410
|
+
// emitted line numbers 1-based relative to the file.
|
|
411
|
+
line: line + 1,
|
|
412
|
+
column: 1,
|
|
413
|
+
}, bodyAst);
|
|
200
414
|
return {
|
|
201
415
|
displayId,
|
|
202
416
|
title: title ?? "",
|
|
203
417
|
body,
|
|
418
|
+
bodyAst,
|
|
204
419
|
rawAttributes: attributes,
|
|
205
420
|
typedAttributes: (0, attributes_js_1.collateAttributes)(attributes),
|
|
206
421
|
id,
|
|
207
422
|
type,
|
|
208
423
|
shape,
|
|
209
|
-
location:
|
|
424
|
+
location: entryLocation,
|
|
210
425
|
source: "markdown",
|
|
211
426
|
properties: { file: { path: file, line, column } },
|
|
427
|
+
entityRefs: entityRefs.length > 0 ? entityRefs : undefined,
|
|
212
428
|
};
|
|
213
429
|
}
|
|
214
430
|
/**
|
package/script/parser/mod.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { detectInlineRefs } from "./references.js";
|
|
|
20
20
|
export type { DetectInlineRefsOptions } from "./references.js";
|
|
21
21
|
export { parseSource } from "./source.js";
|
|
22
22
|
export type { ParseSourceOptions, ParseSourceResult } from "./source.js";
|
|
23
|
+
export { stripBlockCommentPrefix, stripLineCommentPrefix, wrapAsListItem, } from "./source.js";
|
|
23
24
|
export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
24
25
|
/** Options for {@linkcode parse}. */
|
|
25
26
|
export interface ParseOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/parser/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAK5E,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE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ANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - source: doc comment extraction from Rust, Kotlin, C, C++, Java
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.loadGrammar = exports.isSupportedExtension = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
|
|
14
|
+
exports.loadGrammar = exports.isSupportedExtension = exports.wrapAsListItem = exports.stripLineCommentPrefix = exports.stripBlockCommentPrefix = exports.parseSource = exports.detectInlineRefs = exports.extractFrontMatter = exports.detectDirectives = void 0;
|
|
15
15
|
exports.parse = parse;
|
|
16
16
|
exports.parseFile = parseFile;
|
|
17
17
|
exports.detectCaptions = detectCaptions;
|
|
@@ -29,6 +29,10 @@ var references_js_1 = require("./references.js");
|
|
|
29
29
|
Object.defineProperty(exports, "detectInlineRefs", { enumerable: true, get: function () { return references_js_1.detectInlineRefs; } });
|
|
30
30
|
var source_js_2 = require("./source.js");
|
|
31
31
|
Object.defineProperty(exports, "parseSource", { enumerable: true, get: function () { return source_js_2.parseSource; } });
|
|
32
|
+
var source_js_3 = require("./source.js");
|
|
33
|
+
Object.defineProperty(exports, "stripBlockCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripBlockCommentPrefix; } });
|
|
34
|
+
Object.defineProperty(exports, "stripLineCommentPrefix", { enumerable: true, get: function () { return source_js_3.stripLineCommentPrefix; } });
|
|
35
|
+
Object.defineProperty(exports, "wrapAsListItem", { enumerable: true, get: function () { return source_js_3.wrapAsListItem; } });
|
|
32
36
|
var grammars_js_2 = require("./grammars.js");
|
|
33
37
|
Object.defineProperty(exports, "isSupportedExtension", { enumerable: true, get: function () { return grammars_js_2.isSupportedExtension; } });
|
|
34
38
|
Object.defineProperty(exports, "loadGrammar", { enumerable: true, get: function () { return grammars_js_2.loadGrammar; } });
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
|
|
6
6
|
* content to the markdown parser for entry extraction.
|
|
7
7
|
*/
|
|
8
|
+
import type { SyntaxNode } from "web-tree-sitter";
|
|
8
9
|
import Parser from "web-tree-sitter";
|
|
9
10
|
import type { Entry } from "../model/mod.js";
|
|
10
11
|
/** Options for {@linkcode parseSource}. */
|
|
@@ -30,4 +31,23 @@ export interface ParseSourceResult {
|
|
|
30
31
|
* @param options - Parse options (language grammar, file path)
|
|
31
32
|
*/
|
|
32
33
|
export declare function parseSource(content: string, options: ParseSourceOptions): ParseSourceResult;
|
|
34
|
+
/**
|
|
35
|
+
* Strip the `///` prefix from a line comment node.
|
|
36
|
+
* Uses the `doc_comment` child if available, otherwise strips manually.
|
|
37
|
+
*/
|
|
38
|
+
export declare function stripLineCommentPrefix(node: SyntaxNode): string;
|
|
39
|
+
/**
|
|
40
|
+
* Strip block comment delimiters and leading ` * ` prefixes.
|
|
41
|
+
* Returns cleaned lines.
|
|
42
|
+
*/
|
|
43
|
+
export declare function stripBlockCommentPrefix(text: string): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Wrap cleaned doc comment lines as a Markdown list item so the
|
|
46
|
+
* existing `parseMarkdown()` can extract entries.
|
|
47
|
+
*
|
|
48
|
+
* Doc comments use `[DISPLAY_ID] Title` without the `- ` bullet.
|
|
49
|
+
* This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
|
|
50
|
+
* recognizes as an entry block.
|
|
51
|
+
*/
|
|
52
|
+
export declare function wrapAsListItem(lines: string[]): string;
|
|
33
53
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/parser/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CACpC;AAED,uCAAuC;AACvC,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;CAC3B;AAYD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,iBAAiB,CAsCnB;AAiFD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAe/D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgC9D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAKtD"}
|
package/script/parser/source.js
CHANGED
|
@@ -11,6 +11,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.parseSource = parseSource;
|
|
14
|
+
exports.stripLineCommentPrefix = stripLineCommentPrefix;
|
|
15
|
+
exports.stripBlockCommentPrefix = stripBlockCommentPrefix;
|
|
16
|
+
exports.wrapAsListItem = wrapAsListItem;
|
|
14
17
|
const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
|
|
15
18
|
const markdown_js_1 = require("./markdown.js");
|
|
16
19
|
/**
|
package/script/profile/chain.js
CHANGED
|
@@ -207,22 +207,12 @@ function stringifySpec(spec) {
|
|
|
207
207
|
* contents are irrelevant.
|
|
208
208
|
*/
|
|
209
209
|
function buildPlaceholderEffective(tiers) {
|
|
210
|
-
const
|
|
210
|
+
const _leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
|
|
211
211
|
return {
|
|
212
|
-
required: { value: [], origin: leafOrigin },
|
|
213
212
|
attributes: new Map(),
|
|
214
|
-
labels:
|
|
213
|
+
labels: new Map(),
|
|
214
|
+
conventions: new Map(),
|
|
215
215
|
colors: new Map(),
|
|
216
|
-
identified: {
|
|
217
|
-
required: { value: [], origin: leafOrigin },
|
|
218
|
-
attributes: new Map(),
|
|
219
|
-
traceability: new Map(),
|
|
220
|
-
},
|
|
221
|
-
referenced: {
|
|
222
|
-
required: { value: [], origin: leafOrigin },
|
|
223
|
-
attributes: new Map(),
|
|
224
|
-
traceability: new Map(),
|
|
225
|
-
},
|
|
226
216
|
types: new Map(),
|
|
227
217
|
documents: { types: new Map(), frontMatter: new Map() },
|
|
228
218
|
};
|
package/script/profile/colors.js
CHANGED
|
@@ -27,7 +27,7 @@ const DEFAULT_HUE = "blue";
|
|
|
27
27
|
* name) so the renderer works for files compiled without a profile.
|
|
28
28
|
*/
|
|
29
29
|
function resolveEntryColor(entry, profile) {
|
|
30
|
-
if (entry.shape === "
|
|
30
|
+
if (entry.shape === "Reference")
|
|
31
31
|
return null;
|
|
32
32
|
if (!profile || !entry.type)
|
|
33
33
|
return DEFAULT_HUE;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/introspect
|
|
3
|
+
*
|
|
4
|
+
* Unified introspection API for profile chains. All discovery surfaces
|
|
5
|
+
* (CLI, MCP, LSP) consume this module instead of re-walking EffectiveProfile.
|
|
6
|
+
*
|
|
7
|
+
* Node-safe: no Deno.* APIs.
|
|
8
|
+
*/
|
|
9
|
+
import type { LabelConcernKind, ProfileChain } from "../model/mod.js";
|
|
10
|
+
/** Discriminant for the five kinds of profile elements. */
|
|
11
|
+
export type ProfileElementKind = "type" | "attribute" | "relation" | "label-concern" | "convention";
|
|
12
|
+
/**
|
|
13
|
+
* A human-readable description with provenance: which profile tier contributed
|
|
14
|
+
* it and which tiers it overrides.
|
|
15
|
+
*/
|
|
16
|
+
export interface ProvenancedDescription {
|
|
17
|
+
readonly text?: string;
|
|
18
|
+
readonly origin?: string;
|
|
19
|
+
readonly overrides?: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A lightweight reference to a profile element, used in overview lists and
|
|
23
|
+
* resolve results. `ref` is `"<kind>/<name>"`, e.g. `"type/software-requirement"`.
|
|
24
|
+
*/
|
|
25
|
+
export interface ProfileElementRef {
|
|
26
|
+
readonly kind: ProfileElementKind;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly summary: string;
|
|
29
|
+
/** `"<kind>/<name>"`, e.g. `"type/software-requirement"`. */
|
|
30
|
+
readonly ref: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* High-level snapshot of the active profile chain: chain tiers and all
|
|
34
|
+
* declared elements as lightweight refs.
|
|
35
|
+
*/
|
|
36
|
+
export interface ProfileOverview {
|
|
37
|
+
readonly tiers: readonly {
|
|
38
|
+
id: string;
|
|
39
|
+
version: string;
|
|
40
|
+
summary: string;
|
|
41
|
+
}[];
|
|
42
|
+
readonly elements: readonly ProfileElementRef[];
|
|
43
|
+
}
|
|
44
|
+
/** Detailed description of a profile-declared entry type. */
|
|
45
|
+
export interface TypeDetail {
|
|
46
|
+
readonly kind: "type";
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly description: ProvenancedDescription;
|
|
49
|
+
readonly extendsTarget: string;
|
|
50
|
+
readonly shape: string;
|
|
51
|
+
readonly displayIdPattern?: string;
|
|
52
|
+
readonly color?: string;
|
|
53
|
+
readonly requiredAttributes: readonly ProfileElementRef[];
|
|
54
|
+
readonly allowedAttributes: readonly ProfileElementRef[];
|
|
55
|
+
readonly outgoingRelations: readonly ProfileElementRef[];
|
|
56
|
+
readonly incomingRelations: readonly ProfileElementRef[];
|
|
57
|
+
}
|
|
58
|
+
/** Detailed description of a universal or type-scoped attribute declaration. */
|
|
59
|
+
export interface AttributeDetail {
|
|
60
|
+
readonly kind: "attribute";
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly description: ProvenancedDescription;
|
|
63
|
+
readonly valueType: string;
|
|
64
|
+
readonly cardinality: string;
|
|
65
|
+
readonly required: boolean;
|
|
66
|
+
readonly enumValues?: readonly string[];
|
|
67
|
+
readonly inverse?: {
|
|
68
|
+
name: string;
|
|
69
|
+
category: string;
|
|
70
|
+
};
|
|
71
|
+
readonly declaredBy: readonly string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Detailed description of a traceability relation, aggregated across all types
|
|
75
|
+
* that declare it.
|
|
76
|
+
*/
|
|
77
|
+
export interface RelationDetail {
|
|
78
|
+
readonly kind: "relation";
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly description: ProvenancedDescription;
|
|
81
|
+
readonly targets: readonly string[];
|
|
82
|
+
readonly cardinality?: string;
|
|
83
|
+
readonly required: boolean;
|
|
84
|
+
readonly declaredBy: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
/** Detailed description of a label concern (enum, set, or flag). */
|
|
87
|
+
export interface LabelConcernDetail {
|
|
88
|
+
readonly kind: "label-concern";
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly description: ProvenancedDescription;
|
|
91
|
+
readonly concernKind: LabelConcernKind;
|
|
92
|
+
readonly values: readonly {
|
|
93
|
+
name: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
}[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Detailed description of a named profile convention (e.g. `modal-keywords`).
|
|
99
|
+
*/
|
|
100
|
+
export interface ConventionDetail {
|
|
101
|
+
readonly kind: "convention";
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly description: ProvenancedDescription;
|
|
104
|
+
readonly settings: Readonly<Record<string, string>>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Discriminated union of all per-element detail types returned by
|
|
108
|
+
* `ProfileIntrospection.describe`.
|
|
109
|
+
*/
|
|
110
|
+
export type ProfileElementDetail = TypeDetail | AttributeDetail | RelationDetail | LabelConcernDetail | ConventionDetail;
|
|
111
|
+
/**
|
|
112
|
+
* Unified read-only view of a profile chain. Consumed by CLI, MCP, and LSP
|
|
113
|
+
* instead of walking `EffectiveProfile` directly.
|
|
114
|
+
*/
|
|
115
|
+
export interface ProfileIntrospection {
|
|
116
|
+
/** Return a lazily computed, cached overview of all profile elements. */
|
|
117
|
+
overview(): ProfileOverview;
|
|
118
|
+
/**
|
|
119
|
+
* Return full detail for the named element, or `undefined` if not found.
|
|
120
|
+
*/
|
|
121
|
+
describe(kind: ProfileElementKind, name: string): ProfileElementDetail | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* Return elements whose kind/name/summary contain all whitespace-separated
|
|
124
|
+
* query tokens (case-insensitive).
|
|
125
|
+
*/
|
|
126
|
+
resolve(query: string): ProfileElementRef[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a `ProfileIntrospection` from a profile chain (or `null` when
|
|
130
|
+
* no profile is configured for the project).
|
|
131
|
+
*
|
|
132
|
+
* The returned object is lazy — `overview()` caches after the first call.
|
|
133
|
+
*/
|
|
134
|
+
export declare function buildProfileIntrospection(chain: ProfileChain | null): ProfileIntrospection;
|
|
135
|
+
//# sourceMappingURL=introspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../src/profile/introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EAChB,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAMzB,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,WAAW,GACX,UAAU,GACV,eAAe,GACf,YAAY,CAA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