@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
package/esm/parser/markdown.js
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* `- [DISPLAY_ID] Title` entry blocks and extract structured attributes.
|
|
6
6
|
*/
|
|
7
7
|
import { IDENTITY_KEY, shapeFromIdValue } from "../model/mod.js";
|
|
8
|
-
import { collateAttributes, parseAttributes, splitBodyAndAttributes, } from "./attributes.js";
|
|
8
|
+
import { ATTR_LINE_RE, collateAttributes, parseAttributes, splitBodyAndAttributes, } from "./attributes.js";
|
|
9
|
+
import { extractEntityRefs } from "./entity_refs.js";
|
|
9
10
|
import { processor } from "./remark.js";
|
|
11
|
+
import { buildBodyAst } from "../ast/build.js";
|
|
10
12
|
/**
|
|
11
13
|
* Slug pattern for referenced-entry display IDs.
|
|
12
14
|
*
|
|
@@ -17,6 +19,10 @@ import { processor } from "./remark.js";
|
|
|
17
19
|
const SLUG_RE = /^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$/;
|
|
18
20
|
/** Match `[...]` at the start of a list item paragraph. Captures: [1] = display ID, [2] = title. */
|
|
19
21
|
const ENTRY_START_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
22
|
+
/** Match `[]` at the start — empty brackets. */
|
|
23
|
+
const EMPTY_BRACKET_RE = /^\[\]\s*(.*)$/;
|
|
24
|
+
/** Match `[` at the start without a closing `]` on the same logical content — unterminated. */
|
|
25
|
+
const UNTERMINATED_BRACKET_RE = /^\[[^\]]*$/;
|
|
20
26
|
/**
|
|
21
27
|
* Find the `Id:` attribute on an entry. Returns undefined when absent. If
|
|
22
28
|
* more than one `Id:` is present, returns the first — the validator flags
|
|
@@ -105,11 +111,36 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
105
111
|
let title;
|
|
106
112
|
if (firstInline.type === "text") {
|
|
107
113
|
// remark may parse `[ID] Title` as a single text node
|
|
108
|
-
const
|
|
114
|
+
const textValue = firstInline.value;
|
|
115
|
+
const match = ENTRY_START_RE.exec(textValue);
|
|
109
116
|
if (match) {
|
|
110
117
|
displayId = match[1];
|
|
111
118
|
title = match[2].trim();
|
|
112
119
|
}
|
|
120
|
+
else if (EMPTY_BRACKET_RE.test(textValue)) {
|
|
121
|
+
// MSL-P001: bracketed content is empty — `- [] Title`
|
|
122
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
123
|
+
diagnostics.push({
|
|
124
|
+
code: "MSL-P001",
|
|
125
|
+
severity: "error",
|
|
126
|
+
message: "list item starts with `[]` but the bracketed content is empty " +
|
|
127
|
+
"(spec section 4.1)",
|
|
128
|
+
location: { file, line: entryLine, column: 1 },
|
|
129
|
+
});
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
else if (UNTERMINATED_BRACKET_RE.test(textValue)) {
|
|
133
|
+
// MSL-P003: display-ID brackets unterminated (missing `]`)
|
|
134
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
135
|
+
diagnostics.push({
|
|
136
|
+
code: "MSL-P003",
|
|
137
|
+
severity: "error",
|
|
138
|
+
message: "display-ID brackets unterminated -- missing `]` before end of " +
|
|
139
|
+
"title line (spec section 4.1)",
|
|
140
|
+
location: { file, line: entryLine, column: 1 },
|
|
141
|
+
});
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
113
144
|
}
|
|
114
145
|
// Try linkReference pattern: remark sometimes parses [ID] as a linkReference
|
|
115
146
|
if (!displayId && firstInline.type === "linkReference") {
|
|
@@ -140,10 +171,168 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
140
171
|
// citation compatibility. Canonical slug never contains `@`.
|
|
141
172
|
if (displayId.startsWith("@"))
|
|
142
173
|
displayId = displayId.slice(1);
|
|
174
|
+
// MSL-I005: Display ID is empty (after `@` stripping).
|
|
175
|
+
if (displayId.length === 0) {
|
|
176
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
177
|
+
diagnostics.push({
|
|
178
|
+
code: "MSL-I005",
|
|
179
|
+
severity: "error",
|
|
180
|
+
message: "display ID is empty (spec section 4.2)",
|
|
181
|
+
location: { file, line: entryLine, column: 1 },
|
|
182
|
+
});
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
// MSL-P002: title text missing after `]`. The title capture is empty
|
|
186
|
+
// and was not populated from subsequent nodes (linkReference path sets
|
|
187
|
+
// title from rest nodes).
|
|
188
|
+
if (title !== undefined && title.length === 0) {
|
|
189
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
190
|
+
diagnostics.push({
|
|
191
|
+
code: "MSL-P002",
|
|
192
|
+
severity: "error",
|
|
193
|
+
message: `${displayId}: title line missing title text after ']' (spec section 4.1)`,
|
|
194
|
+
location: { file, line: entryLine, column: 1 },
|
|
195
|
+
});
|
|
196
|
+
// Continue parsing — entry is still structurally valid for downstream
|
|
197
|
+
// validation (MSL-P010 also fires from the validator for empty titles).
|
|
198
|
+
}
|
|
143
199
|
// Extract body content and attributes.
|
|
144
200
|
const bodyContent = extractBodyContent(item, markdown);
|
|
145
201
|
const [body, attrLines] = splitBodyAndAttributes(bodyContent);
|
|
146
202
|
const attributes = parseAttributes(attrLines);
|
|
203
|
+
const bodyAst = buildBodyAst(body);
|
|
204
|
+
const entryLine = item.position?.start.line ?? 1;
|
|
205
|
+
// MSL-P020: trailers block is not the final indented code block.
|
|
206
|
+
// Detect `Key: Value` lines in the body that likely should be trailers
|
|
207
|
+
// but are not at the final position (body content follows them).
|
|
208
|
+
// Exclude caption keywords (Figure:, Table:, etc.) which are legitimate
|
|
209
|
+
// body content, not misplaced trailer attributes.
|
|
210
|
+
const CAPTION_KEYWORDS = new Set([
|
|
211
|
+
"Figure",
|
|
212
|
+
"Table",
|
|
213
|
+
"Listing",
|
|
214
|
+
"Feature",
|
|
215
|
+
"Equation",
|
|
216
|
+
"List",
|
|
217
|
+
]);
|
|
218
|
+
if (body.length > 0) {
|
|
219
|
+
const bodyLines = body.split("\n");
|
|
220
|
+
let inFencedBlock = false;
|
|
221
|
+
for (let i = 0; i < bodyLines.length; i++) {
|
|
222
|
+
const trimmed = bodyLines[i].trim();
|
|
223
|
+
// Track fenced code blocks (``` or ~~~) to skip their contents
|
|
224
|
+
if (/^(`{3,}|~{3,})/.test(trimmed)) {
|
|
225
|
+
inFencedBlock = !inFencedBlock;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (inFencedBlock)
|
|
229
|
+
continue;
|
|
230
|
+
if (!ATTR_LINE_RE.test(trimmed))
|
|
231
|
+
continue;
|
|
232
|
+
// Extract the key portion to check against caption keywords
|
|
233
|
+
const keyMatch = trimmed.match(/^([A-Z][A-Za-z-]*):/);
|
|
234
|
+
if (keyMatch && CAPTION_KEYWORDS.has(keyMatch[1]))
|
|
235
|
+
continue;
|
|
236
|
+
// Found a Key: Value line in the body — non-final position
|
|
237
|
+
diagnostics.push({
|
|
238
|
+
code: "MSL-P020",
|
|
239
|
+
severity: "error",
|
|
240
|
+
message: `${displayId}: trailers block is not the final indented code ` +
|
|
241
|
+
`block of the entry -- content appears after trailer-like ` +
|
|
242
|
+
`lines (spec section 4.1)`,
|
|
243
|
+
location: { file, line: entryLine, column: 1 },
|
|
244
|
+
});
|
|
245
|
+
break; // One diagnostic per entry is sufficient
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// MSL-P021 / MSL-P022: validate trailer lines for syntax correctness.
|
|
249
|
+
// The trailer block is the final indented code block. Lines within it
|
|
250
|
+
// should all match `Key: Value` syntax. We check both the parsed
|
|
251
|
+
// attrLines AND the trailing body lines that might be in a code block
|
|
252
|
+
// but failed ATTR_LINE_RE (thus stayed in the body).
|
|
253
|
+
const TRAILER_KEY_RE = /^[A-Za-z][A-Za-z0-9-]*$/;
|
|
254
|
+
const COLON_SPLIT_RE = /^([^:]+):\s*(.*)$/;
|
|
255
|
+
// Check lines that DID end up in attrLines but might have key issues
|
|
256
|
+
for (const rawLine of attrLines) {
|
|
257
|
+
const trimmed = rawLine.trim();
|
|
258
|
+
if (!trimmed)
|
|
259
|
+
continue;
|
|
260
|
+
if (!ATTR_LINE_RE.test(trimmed)) {
|
|
261
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
262
|
+
if (colonMatch) {
|
|
263
|
+
const key = colonMatch[1].trim();
|
|
264
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
265
|
+
diagnostics.push({
|
|
266
|
+
code: "MSL-P022",
|
|
267
|
+
severity: "error",
|
|
268
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
269
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
270
|
+
location: { file, line: entryLine, column: 1 },
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
diagnostics.push({
|
|
275
|
+
code: "MSL-P021",
|
|
276
|
+
severity: "error",
|
|
277
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
278
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
279
|
+
location: { file, line: entryLine, column: 1 },
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
diagnostics.push({
|
|
285
|
+
code: "MSL-P021",
|
|
286
|
+
severity: "error",
|
|
287
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
288
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
289
|
+
location: { file, line: entryLine, column: 1 },
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Also scan trailing body lines for suspected misplaced trailers.
|
|
295
|
+
// If the body's last non-empty lines look like they belong to an
|
|
296
|
+
// indented code block with colon-separated content that has invalid
|
|
297
|
+
// keys, emit P022. Lines without colons that appear in what looks
|
|
298
|
+
// like a trailer block emit P021.
|
|
299
|
+
if (body.length > 0) {
|
|
300
|
+
const bodyLines = body.split("\n");
|
|
301
|
+
// Walk backward from the end of the body to find lines in a trailing
|
|
302
|
+
// code-block-like region that have colons (suspected trailers).
|
|
303
|
+
for (let i = bodyLines.length - 1; i >= 0; i--) {
|
|
304
|
+
const trimmed = bodyLines[i].trim();
|
|
305
|
+
if (!trimmed)
|
|
306
|
+
continue; // skip trailing blanks
|
|
307
|
+
const colonMatch = COLON_SPLIT_RE.exec(trimmed);
|
|
308
|
+
if (!colonMatch)
|
|
309
|
+
break; // stop at non-colon line
|
|
310
|
+
const key = colonMatch[1].trim();
|
|
311
|
+
if (ATTR_LINE_RE.test(trimmed)) {
|
|
312
|
+
// Valid attr line in body → already caught by P020
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (!TRAILER_KEY_RE.test(key)) {
|
|
316
|
+
diagnostics.push({
|
|
317
|
+
code: "MSL-P022",
|
|
318
|
+
severity: "error",
|
|
319
|
+
message: `${displayId}: trailer key '${key}' contains characters ` +
|
|
320
|
+
`outside [A-Za-z][A-Za-z0-9-]* (spec section 4.1)`,
|
|
321
|
+
location: { file, line: entryLine, column: 1 },
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
else if (colonMatch[2].trim().length === 0) {
|
|
325
|
+
diagnostics.push({
|
|
326
|
+
code: "MSL-P021",
|
|
327
|
+
severity: "error",
|
|
328
|
+
message: `${displayId}: trailer line does not match 'Key: Value' ` +
|
|
329
|
+
`syntax (spec section 4.1): "${trimmed}"`,
|
|
330
|
+
location: { file, line: entryLine, column: 1 },
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
break; // one diagnostic per trailing suspect line is sufficient
|
|
334
|
+
}
|
|
335
|
+
}
|
|
147
336
|
// Detect legacy paragraph + trailing-backslash attribute form and warn.
|
|
148
337
|
if (attributes.length > 0 &&
|
|
149
338
|
attrLines.some((line) => line.trimEnd().endsWith("\\"))) {
|
|
@@ -167,45 +356,72 @@ function extractEntry(item, markdown, file, definitions, isReferencesDoc, diagno
|
|
|
167
356
|
// `Id:` is neither a ULID nor a scheme-qualified URI. Accept as an
|
|
168
357
|
// identified entry so the validator can surface MSL-R004; missing
|
|
169
358
|
// shape on a parsed entry is not useful downstream.
|
|
170
|
-
shape = "
|
|
359
|
+
shape = "Authored";
|
|
171
360
|
}
|
|
172
361
|
}
|
|
173
362
|
else {
|
|
174
363
|
// No `Id:`. Fall back on display-ID shape + document context to decide
|
|
175
364
|
// whether to admit the entry at all.
|
|
176
365
|
if (isReferencesDoc && SLUG_RE.test(displayId)) {
|
|
177
|
-
shape = "
|
|
366
|
+
shape = "Reference";
|
|
178
367
|
}
|
|
179
368
|
else {
|
|
180
369
|
// No identity attribute and no references-doc context — admit as
|
|
181
370
|
// identified so the validator can surface the missing-`Id:` error.
|
|
182
|
-
shape = "
|
|
371
|
+
shape = "Authored";
|
|
183
372
|
}
|
|
184
373
|
}
|
|
185
374
|
// Inferred type from display-ID prefix — left to the profile layer. For
|
|
186
375
|
// now the core records no type; downstream profile-aware code populates
|
|
187
376
|
// this field when a profile is loaded.
|
|
188
377
|
const type = undefined;
|
|
378
|
+
// MSL-P030: Authored entry has no body block (title + trailers only).
|
|
379
|
+
// For Reference shape, body is optional (ADR-002 section Part 3). For Authored,
|
|
380
|
+
// the body is required. We also emit P030 when the body is empty (all
|
|
381
|
+
// content was consumed as attributes).
|
|
382
|
+
if (shape === "Authored" && body.trim().length === 0) {
|
|
383
|
+
diagnostics.push({
|
|
384
|
+
code: "MSL-P030",
|
|
385
|
+
severity: "error",
|
|
386
|
+
message: `${displayId}: Authored entry has no body block -- entries must ` +
|
|
387
|
+
`have body content between title and trailers (spec section 4.1)`,
|
|
388
|
+
location: { file, line: entryLine, column: 1 },
|
|
389
|
+
});
|
|
390
|
+
}
|
|
189
391
|
// Body requirement: identified entries require a body; referenced entries
|
|
190
392
|
// may omit it. If there's only one child (the title paragraph), admit
|
|
191
393
|
// only referenced entries.
|
|
192
|
-
if (shape !== "
|
|
394
|
+
if (shape !== "Reference" && item.children.length < 2)
|
|
193
395
|
return undefined;
|
|
194
396
|
// Source location
|
|
195
397
|
const line = item.position?.start.line ?? 1;
|
|
196
398
|
const column = item.position?.start.column ?? 1;
|
|
399
|
+
const entryLocation = { file, line, column };
|
|
400
|
+
// Inline `$Identifier` entity references (spec section 2.5.2). Resolution
|
|
401
|
+
// into the project's entity registry is left to the validator's
|
|
402
|
+
// marker pass; the parser only emits the lexical hits.
|
|
403
|
+
// Pass the already-built bodyAst to avoid a redundant mdast parse.
|
|
404
|
+
const entityRefs = extractEntityRefs(body, {
|
|
405
|
+
file,
|
|
406
|
+
// Body content starts on the line after the title; +1 keeps
|
|
407
|
+
// emitted line numbers 1-based relative to the file.
|
|
408
|
+
line: line + 1,
|
|
409
|
+
column: 1,
|
|
410
|
+
}, bodyAst);
|
|
197
411
|
return {
|
|
198
412
|
displayId,
|
|
199
413
|
title: title ?? "",
|
|
200
414
|
body,
|
|
415
|
+
bodyAst,
|
|
201
416
|
rawAttributes: attributes,
|
|
202
417
|
typedAttributes: collateAttributes(attributes),
|
|
203
418
|
id,
|
|
204
419
|
type,
|
|
205
420
|
shape,
|
|
206
|
-
location:
|
|
421
|
+
location: entryLocation,
|
|
207
422
|
source: "markdown",
|
|
208
423
|
properties: { file: { path: file, line, column } },
|
|
424
|
+
entityRefs: entityRefs.length > 0 ? entityRefs : undefined,
|
|
209
425
|
};
|
|
210
426
|
}
|
|
211
427
|
/**
|
package/esm/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 {
|
package/esm/parser/mod.d.ts.map
CHANGED
|
@@ -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,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AE,qBAAqB,GAC9B,OAAO,EAAE,CAEX"}
|
package/esm/parser/mod.js
CHANGED
|
@@ -19,6 +19,7 @@ export { detectDirectives } from "./directives.js";
|
|
|
19
19
|
export { extractFrontMatter } from "./frontmatter.js";
|
|
20
20
|
export { detectInlineRefs } from "./references.js";
|
|
21
21
|
export { parseSource } from "./source.js";
|
|
22
|
+
export { stripBlockCommentPrefix, stripLineCommentPrefix, wrapAsListItem, } from "./source.js";
|
|
22
23
|
export { isSupportedExtension, loadGrammar } from "./grammars.js";
|
|
23
24
|
/**
|
|
24
25
|
* Parse a Markdown string and return all MarkSpec entries found.
|
package/esm/parser/source.d.ts
CHANGED
|
@@ -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/esm/parser/source.js
CHANGED
|
@@ -122,7 +122,7 @@ function isOuterDocComment(node) {
|
|
|
122
122
|
* Strip the `///` prefix from a line comment node.
|
|
123
123
|
* Uses the `doc_comment` child if available, otherwise strips manually.
|
|
124
124
|
*/
|
|
125
|
-
function stripLineCommentPrefix(node) {
|
|
125
|
+
export function stripLineCommentPrefix(node) {
|
|
126
126
|
for (let i = 0; i < node.childCount; i++) {
|
|
127
127
|
const child = node.child(i);
|
|
128
128
|
if (child.type === "doc_comment") {
|
|
@@ -145,7 +145,7 @@ function stripLineCommentPrefix(node) {
|
|
|
145
145
|
* Strip block comment delimiters and leading ` * ` prefixes.
|
|
146
146
|
* Returns cleaned lines.
|
|
147
147
|
*/
|
|
148
|
-
function stripBlockCommentPrefix(text) {
|
|
148
|
+
export function stripBlockCommentPrefix(text) {
|
|
149
149
|
const rawLines = text.split("\n");
|
|
150
150
|
const result = [];
|
|
151
151
|
for (let i = 0; i < rawLines.length; i++) {
|
|
@@ -183,7 +183,7 @@ function stripBlockCommentPrefix(text) {
|
|
|
183
183
|
* This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
|
|
184
184
|
* recognizes as an entry block.
|
|
185
185
|
*/
|
|
186
|
-
function wrapAsListItem(lines) {
|
|
186
|
+
export function wrapAsListItem(lines) {
|
|
187
187
|
if (lines.length === 0)
|
|
188
188
|
return "";
|
|
189
189
|
const first = `- ${lines[0]}`;
|
package/esm/profile/chain.js
CHANGED
|
@@ -171,22 +171,12 @@ function stringifySpec(spec) {
|
|
|
171
171
|
* contents are irrelevant.
|
|
172
172
|
*/
|
|
173
173
|
function buildPlaceholderEffective(tiers) {
|
|
174
|
-
const
|
|
174
|
+
const _leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
|
|
175
175
|
return {
|
|
176
|
-
required: { value: [], origin: leafOrigin },
|
|
177
176
|
attributes: new Map(),
|
|
178
|
-
labels:
|
|
177
|
+
labels: new Map(),
|
|
178
|
+
conventions: new Map(),
|
|
179
179
|
colors: new Map(),
|
|
180
|
-
identified: {
|
|
181
|
-
required: { value: [], origin: leafOrigin },
|
|
182
|
-
attributes: new Map(),
|
|
183
|
-
traceability: new Map(),
|
|
184
|
-
},
|
|
185
|
-
referenced: {
|
|
186
|
-
required: { value: [], origin: leafOrigin },
|
|
187
|
-
attributes: new Map(),
|
|
188
|
-
traceability: new Map(),
|
|
189
|
-
},
|
|
190
180
|
types: new Map(),
|
|
191
181
|
documents: { types: new Map(), frontMatter: new Map() },
|
|
192
182
|
};
|
package/esm/profile/colors.js
CHANGED
|
@@ -24,7 +24,7 @@ const DEFAULT_HUE = "blue";
|
|
|
24
24
|
* name) so the renderer works for files compiled without a profile.
|
|
25
25
|
*/
|
|
26
26
|
export function resolveEntryColor(entry, profile) {
|
|
27
|
-
if (entry.shape === "
|
|
27
|
+
if (entry.shape === "Reference")
|
|
28
28
|
return null;
|
|
29
29
|
if (!profile || !entry.type)
|
|
30
30
|
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,CAAC;AAEjB;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAA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