@driftsys/markspec 0.1.0 → 0.3.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.
Files changed (242) hide show
  1. package/README.md +32 -8
  2. package/esm/_dnt.polyfills.d.ts +101 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -0
  4. package/esm/_dnt.polyfills.js +127 -0
  5. package/esm/compiler/inverses.d.ts +22 -0
  6. package/esm/compiler/inverses.d.ts.map +1 -0
  7. package/esm/compiler/inverses.js +147 -0
  8. package/esm/compiler/link_target.d.ts +19 -0
  9. package/esm/compiler/link_target.d.ts.map +1 -0
  10. package/esm/compiler/link_target.js +66 -0
  11. package/esm/compiler/mod.d.ts +43 -0
  12. package/esm/compiler/mod.d.ts.map +1 -0
  13. package/esm/compiler/mod.js +163 -0
  14. package/esm/compiler/schema.d.ts +38 -0
  15. package/esm/compiler/schema.d.ts.map +1 -0
  16. package/esm/compiler/schema.js +44 -0
  17. package/esm/config/markspec.d.ts +51 -0
  18. package/esm/config/markspec.d.ts.map +1 -0
  19. package/esm/config/markspec.js +216 -0
  20. package/esm/config/mod.d.ts +48 -0
  21. package/esm/config/mod.d.ts.map +1 -0
  22. package/esm/config/mod.js +243 -0
  23. package/esm/formatter/mod.d.ts +65 -0
  24. package/esm/formatter/mod.d.ts.map +1 -0
  25. package/esm/formatter/mod.js +306 -0
  26. package/esm/mod.d.ts +19 -0
  27. package/esm/mod.d.ts.map +1 -1
  28. package/esm/mod.js +18 -0
  29. package/esm/model/attributes.d.ts +47 -0
  30. package/esm/model/attributes.d.ts.map +1 -0
  31. package/esm/model/attributes.js +97 -0
  32. package/esm/model/mod.d.ts +381 -0
  33. package/esm/model/mod.d.ts.map +1 -0
  34. package/esm/model/mod.js +73 -0
  35. package/esm/model/profile.d.ts +189 -0
  36. package/esm/model/profile.d.ts.map +1 -0
  37. package/esm/model/profile.js +31 -0
  38. package/esm/parser/attributes.d.ts +48 -0
  39. package/esm/parser/attributes.d.ts.map +1 -0
  40. package/esm/parser/attributes.js +131 -0
  41. package/esm/parser/captions.d.ts +25 -0
  42. package/esm/parser/captions.d.ts.map +1 -0
  43. package/esm/parser/captions.js +148 -0
  44. package/esm/parser/directives.d.ts +29 -0
  45. package/esm/parser/directives.d.ts.map +1 -0
  46. package/esm/parser/directives.js +88 -0
  47. package/esm/parser/frontmatter.d.ts +53 -0
  48. package/esm/parser/frontmatter.d.ts.map +1 -0
  49. package/esm/parser/frontmatter.js +185 -0
  50. package/esm/parser/grammars.d.ts +22 -0
  51. package/esm/parser/grammars.d.ts.map +1 -0
  52. package/esm/parser/grammars.js +70 -0
  53. package/esm/parser/markdown.d.ts +32 -0
  54. package/esm/parser/markdown.d.ts.map +1 -0
  55. package/esm/parser/markdown.js +225 -0
  56. package/esm/parser/mod.d.ts +73 -0
  57. package/esm/parser/mod.d.ts.map +1 -0
  58. package/esm/parser/mod.js +89 -0
  59. package/esm/parser/references.d.ts +24 -0
  60. package/esm/parser/references.d.ts.map +1 -0
  61. package/esm/parser/references.js +71 -0
  62. package/esm/parser/remark.d.ts +9 -0
  63. package/esm/parser/remark.d.ts.map +1 -0
  64. package/esm/parser/remark.js +11 -0
  65. package/esm/parser/source.d.ts +33 -0
  66. package/esm/parser/source.d.ts.map +1 -0
  67. package/esm/parser/source.js +192 -0
  68. package/esm/profile/cache.d.ts +29 -0
  69. package/esm/profile/cache.d.ts.map +1 -0
  70. package/esm/profile/cache.js +45 -0
  71. package/esm/profile/chain.d.ts +42 -0
  72. package/esm/profile/chain.d.ts.map +1 -0
  73. package/esm/profile/chain.js +193 -0
  74. package/esm/profile/git-cache.d.ts +73 -0
  75. package/esm/profile/git-cache.d.ts.map +1 -0
  76. package/esm/profile/git-cache.js +96 -0
  77. package/esm/profile/load.d.ts +28 -0
  78. package/esm/profile/load.d.ts.map +1 -0
  79. package/esm/profile/load.js +50 -0
  80. package/esm/profile/manifest.d.ts +21 -0
  81. package/esm/profile/manifest.d.ts.map +1 -0
  82. package/esm/profile/manifest.js +830 -0
  83. package/esm/profile/merge.d.ts +26 -0
  84. package/esm/profile/merge.d.ts.map +1 -0
  85. package/esm/profile/merge.js +518 -0
  86. package/esm/profile/mod.d.ts +23 -0
  87. package/esm/profile/mod.d.ts.map +1 -0
  88. package/esm/profile/mod.js +14 -0
  89. package/esm/profile/npm.d.ts +51 -0
  90. package/esm/profile/npm.d.ts.map +1 -0
  91. package/esm/profile/npm.js +186 -0
  92. package/esm/profile/resolver.d.ts +60 -0
  93. package/esm/profile/resolver.d.ts.map +1 -0
  94. package/esm/profile/resolver.js +132 -0
  95. package/esm/reporter/mod.d.ts +31 -0
  96. package/esm/reporter/mod.d.ts.map +1 -0
  97. package/esm/reporter/mod.js +173 -0
  98. package/esm/validator/attributes.d.ts +43 -0
  99. package/esm/validator/attributes.d.ts.map +1 -0
  100. package/esm/validator/attributes.js +169 -0
  101. package/esm/validator/mod.d.ts +44 -0
  102. package/esm/validator/mod.d.ts.map +1 -0
  103. package/esm/validator/mod.js +214 -0
  104. package/esm/validator/normalize.d.ts +21 -0
  105. package/esm/validator/normalize.d.ts.map +1 -0
  106. package/esm/validator/normalize.js +58 -0
  107. package/esm/validator/pattern.d.ts +23 -0
  108. package/esm/validator/pattern.d.ts.map +1 -0
  109. package/esm/validator/pattern.js +44 -0
  110. package/esm/validator/pipeline.d.ts +30 -0
  111. package/esm/validator/pipeline.d.ts.map +1 -0
  112. package/esm/validator/pipeline.js +115 -0
  113. package/esm/validator/traceability.d.ts +48 -0
  114. package/esm/validator/traceability.d.ts.map +1 -0
  115. package/esm/validator/traceability.js +141 -0
  116. package/esm/validator/types.d.ts +48 -0
  117. package/esm/validator/types.d.ts.map +1 -0
  118. package/esm/validator/types.js +140 -0
  119. package/esm/validator/value_types.d.ts +20 -0
  120. package/esm/validator/value_types.d.ts.map +1 -0
  121. package/esm/validator/value_types.js +126 -0
  122. package/package.json +8 -1
  123. package/script/_dnt.polyfills.d.ts +101 -0
  124. package/script/_dnt.polyfills.d.ts.map +1 -0
  125. package/script/_dnt.polyfills.js +130 -0
  126. package/script/compiler/inverses.d.ts +22 -0
  127. package/script/compiler/inverses.d.ts.map +1 -0
  128. package/script/compiler/inverses.js +150 -0
  129. package/script/compiler/link_target.d.ts +19 -0
  130. package/script/compiler/link_target.d.ts.map +1 -0
  131. package/script/compiler/link_target.js +69 -0
  132. package/script/compiler/mod.d.ts +43 -0
  133. package/script/compiler/mod.d.ts.map +1 -0
  134. package/script/compiler/mod.js +169 -0
  135. package/script/compiler/schema.d.ts +38 -0
  136. package/script/compiler/schema.d.ts.map +1 -0
  137. package/script/compiler/schema.js +47 -0
  138. package/script/config/markspec.d.ts +51 -0
  139. package/script/config/markspec.d.ts.map +1 -0
  140. package/script/config/markspec.js +222 -0
  141. package/script/config/mod.d.ts +48 -0
  142. package/script/config/mod.d.ts.map +1 -0
  143. package/script/config/mod.js +250 -0
  144. package/script/formatter/mod.d.ts +65 -0
  145. package/script/formatter/mod.d.ts.map +1 -0
  146. package/script/formatter/mod.js +313 -0
  147. package/script/mod.d.ts +19 -0
  148. package/script/mod.d.ts.map +1 -1
  149. package/script/mod.js +65 -2
  150. package/script/model/attributes.d.ts +47 -0
  151. package/script/model/attributes.d.ts.map +1 -0
  152. package/script/model/attributes.js +101 -0
  153. package/script/model/mod.d.ts +381 -0
  154. package/script/model/mod.d.ts.map +1 -0
  155. package/script/model/mod.js +83 -0
  156. package/script/model/profile.d.ts +189 -0
  157. package/script/model/profile.d.ts.map +1 -0
  158. package/script/model/profile.js +34 -0
  159. package/script/parser/attributes.d.ts +48 -0
  160. package/script/parser/attributes.d.ts.map +1 -0
  161. package/script/parser/attributes.js +137 -0
  162. package/script/parser/captions.d.ts +25 -0
  163. package/script/parser/captions.d.ts.map +1 -0
  164. package/script/parser/captions.js +151 -0
  165. package/script/parser/directives.d.ts +29 -0
  166. package/script/parser/directives.d.ts.map +1 -0
  167. package/script/parser/directives.js +91 -0
  168. package/script/parser/frontmatter.d.ts +53 -0
  169. package/script/parser/frontmatter.d.ts.map +1 -0
  170. package/script/parser/frontmatter.js +188 -0
  171. package/script/parser/grammars.d.ts +22 -0
  172. package/script/parser/grammars.d.ts.map +1 -0
  173. package/script/parser/grammars.js +77 -0
  174. package/script/parser/markdown.d.ts +32 -0
  175. package/script/parser/markdown.d.ts.map +1 -0
  176. package/script/parser/markdown.js +228 -0
  177. package/script/parser/mod.d.ts +73 -0
  178. package/script/parser/mod.d.ts.map +1 -0
  179. package/script/parser/mod.js +101 -0
  180. package/script/parser/references.d.ts +24 -0
  181. package/script/parser/references.d.ts.map +1 -0
  182. package/script/parser/references.js +74 -0
  183. package/script/parser/remark.d.ts +9 -0
  184. package/script/parser/remark.d.ts.map +1 -0
  185. package/script/parser/remark.js +17 -0
  186. package/script/parser/source.d.ts +33 -0
  187. package/script/parser/source.d.ts.map +1 -0
  188. package/script/parser/source.js +198 -0
  189. package/script/profile/cache.d.ts +29 -0
  190. package/script/profile/cache.d.ts.map +1 -0
  191. package/script/profile/cache.js +48 -0
  192. package/script/profile/chain.d.ts +42 -0
  193. package/script/profile/chain.d.ts.map +1 -0
  194. package/script/profile/chain.js +229 -0
  195. package/script/profile/git-cache.d.ts +73 -0
  196. package/script/profile/git-cache.d.ts.map +1 -0
  197. package/script/profile/git-cache.js +104 -0
  198. package/script/profile/load.d.ts +28 -0
  199. package/script/profile/load.d.ts.map +1 -0
  200. package/script/profile/load.js +53 -0
  201. package/script/profile/manifest.d.ts +21 -0
  202. package/script/profile/manifest.d.ts.map +1 -0
  203. package/script/profile/manifest.js +833 -0
  204. package/script/profile/merge.d.ts +26 -0
  205. package/script/profile/merge.d.ts.map +1 -0
  206. package/script/profile/merge.js +521 -0
  207. package/script/profile/mod.d.ts +23 -0
  208. package/script/profile/mod.d.ts.map +1 -0
  209. package/script/profile/mod.js +31 -0
  210. package/script/profile/npm.d.ts +51 -0
  211. package/script/profile/npm.d.ts.map +1 -0
  212. package/script/profile/npm.js +191 -0
  213. package/script/profile/resolver.d.ts +60 -0
  214. package/script/profile/resolver.d.ts.map +1 -0
  215. package/script/profile/resolver.js +136 -0
  216. package/script/reporter/mod.d.ts +31 -0
  217. package/script/reporter/mod.d.ts.map +1 -0
  218. package/script/reporter/mod.js +176 -0
  219. package/script/validator/attributes.d.ts +43 -0
  220. package/script/validator/attributes.d.ts.map +1 -0
  221. package/script/validator/attributes.js +173 -0
  222. package/script/validator/mod.d.ts +44 -0
  223. package/script/validator/mod.d.ts.map +1 -0
  224. package/script/validator/mod.js +231 -0
  225. package/script/validator/normalize.d.ts +21 -0
  226. package/script/validator/normalize.d.ts.map +1 -0
  227. package/script/validator/normalize.js +61 -0
  228. package/script/validator/pattern.d.ts +23 -0
  229. package/script/validator/pattern.d.ts.map +1 -0
  230. package/script/validator/pattern.js +47 -0
  231. package/script/validator/pipeline.d.ts +30 -0
  232. package/script/validator/pipeline.d.ts.map +1 -0
  233. package/script/validator/pipeline.js +118 -0
  234. package/script/validator/traceability.d.ts +48 -0
  235. package/script/validator/traceability.d.ts.map +1 -0
  236. package/script/validator/traceability.js +146 -0
  237. package/script/validator/types.d.ts +48 -0
  238. package/script/validator/types.d.ts.map +1 -0
  239. package/script/validator/types.js +144 -0
  240. package/script/validator/value_types.d.ts +20 -0
  241. package/script/validator/value_types.d.ts.map +1 -0
  242. package/script/validator/value_types.js +129 -0
package/README.md CHANGED
@@ -9,8 +9,10 @@
9
9
  A Markdown flavor for traceable industrial documentation, and a CLI toolchain
10
10
  that processes it.
11
11
 
12
- > Early development. The [language specification](docs/spec/language.md) is
13
- > stable. Tooling is not yet functional.
12
+ > Early development. The
13
+ > [language specification](docs/spec/language/language.md) is under active
14
+ > revision to match ADR-009 (core/profile boundary). Tooling is not yet
15
+ > functional.
14
16
 
15
17
  ## Tools
16
18
 
@@ -18,8 +20,10 @@ that processes it.
18
20
  markspec format # stamp ULIDs, normalize attributes
19
21
  markspec validate # check broken refs, missing Ids
20
22
  markspec compile <paths> # build traceability graph → JSON
23
+ # (ingests deps via SBOM tooling if configured)
21
24
  markspec export # JSON → csv, reqif, yaml
22
- markspec insert # scaffold requirement block
25
+ markspec insert # scaffold entry block
26
+ markspec profile # add / publish / manage profiles
23
27
 
24
28
  markspec doc build # document PDF
25
29
  markspec book build # PDF + HTML book
@@ -35,7 +39,7 @@ markspec mcp # MCP server
35
39
 
36
40
  ```text
37
41
  core/ ← parser, validator, compiler, reporter, formatter
38
- render/ ← Typst WASM, Mustache substitution, captions
42
+ render/ ← Typst WASM, entry block rendering, Mustache substitution, captions
39
43
  book/ ← multi-file PDF + HTML book builder
40
44
  deck/ ← Touying-based slide deck builder
41
45
  cli/ ← subcommand handlers
@@ -50,7 +54,7 @@ One binary. One install. Three rendering targets (document, book, deck).
50
54
  MarkSpec extends CommonMark with constructs that render as plain Markdown on
51
55
  GitHub and GitLab — no tooling required to read.
52
56
 
53
- **Entry blocks** — a list item with a typed ID and an indented body:
57
+ **Entry blocks** — a list item with a display ID and an indented body:
54
58
 
55
59
  ```markdown
56
60
  - [SRS_BRK_0001] Sensor input debouncing
@@ -58,11 +62,25 @@ GitHub and GitLab — no tooling required to read.
58
62
  The sensor driver shall debounce raw inputs to eliminate electrical noise
59
63
  before processing.
60
64
 
61
- Id: SRS_01HGW2Q8MNP3\
65
+ Id: 01HGW2Q8MNP3RSTVWXYZABCDEF\
62
66
  Satisfies: SYS_BRK_0042\
63
67
  Labels: ASIL-B
64
68
  ```
65
69
 
70
+ Every entry carries a single `Id:` attribute. A ULID value identifies an
71
+ **identified** entry (content the project authors); a URI value (`urn:`, `doi:`,
72
+ `pkg:`, `https:`, …) identifies a **referenced** entry (citation of an external
73
+ artifact). The entry's type (requirement, test, unit, standard, dependency, …)
74
+ is inferred by the active profile from the display-ID prefix (`SRS_` →
75
+ `type: software-requirement`); compliance vocabulary comes from the active
76
+ profile.
77
+
78
+ In PDF output, entry blocks render as admonition-style blocks with
79
+ profile-driven color-coding by type, label pills on the title line, and italic
80
+ metadata with dashed-underline cross-references. See
81
+ [`docs/examples/entry-rendering.md`](docs/examples/entry-rendering.md) for a
82
+ full showcase.
83
+
66
84
  **Table captions** — emphasized paragraph above a pipe table:
67
85
 
68
86
  ```markdown
@@ -81,7 +99,7 @@ _Table: Sensor thresholds_
81
99
  _Figure: High-level architecture of the braking system_
82
100
  ```
83
101
 
84
- **In-code entries** — requirements in doc comments, same format:
102
+ **In-code entries** — entries in doc comments, same format:
85
103
 
86
104
  ```rust
87
105
  /// [SRS_BRK_0001] Sensor input debouncing
@@ -89,7 +107,7 @@ _Figure: High-level architecture of the braking system_
89
107
  /// The sensor driver shall reject transient noise shorter
90
108
  /// than the configured debounce window.
91
109
  ///
92
- /// Id: SRS_01HGW2Q8MNP3 \
110
+ /// Id: 01HGW2Q8MNP3RSTVWXYZABCDEF \
93
111
  /// Satisfies: SYS_BRK_0042 \
94
112
  /// Labels: ASIL-B
95
113
  #[test]
@@ -108,3 +126,9 @@ resolved at build time.
108
126
  ---
109
127
 
110
128
  Part of the [DriftSys](https://github.com/driftsys) ecosystem.
129
+
130
+ <!-- git-std:bootstrap -->
131
+
132
+ ## Post-clone setup
133
+
134
+ Run `./bootstrap` after `git clone` or `git worktree add`.
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ import { createRequire } from "node:module";
14
+ import { type URL } from "node:url";
15
+ declare global {
16
+ interface ImportMeta {
17
+ /** A string representation of the fully qualified module URL. When the
18
+ * module is loaded locally, the value will be a file URL (e.g.
19
+ * `file:///path/module.ts`).
20
+ *
21
+ * You can also parse the string as a URL to determine more information about
22
+ * how the current module was loaded. For example to determine if a module was
23
+ * local or not:
24
+ *
25
+ * ```ts
26
+ * const url = new URL(import.meta.url);
27
+ * if (url.protocol === "file:") {
28
+ * console.log("this module was loaded locally");
29
+ * }
30
+ * ```
31
+ */
32
+ url: string;
33
+ /**
34
+ * A function that returns resolved specifier as if it would be imported
35
+ * using `import(specifier)`.
36
+ *
37
+ * ```ts
38
+ * console.log(import.meta.resolve("./foo.js"));
39
+ * // file:///dev/foo.js
40
+ * ```
41
+ *
42
+ * @param specifier The module specifier to resolve relative to `parent`.
43
+ * @param parent The absolute parent module URL to resolve from.
44
+ * @returns The absolute (`file:`) URL string for the resolved module.
45
+ */
46
+ resolve(specifier: string, parent?: string | URL | undefined): string;
47
+ /** A flag that indicates if the current module is the main module that was
48
+ * called when starting the program under Deno.
49
+ *
50
+ * ```ts
51
+ * if (import.meta.main) {
52
+ * // this was loaded as the main module, maybe do some bootstrapping
53
+ * }
54
+ * ```
55
+ */
56
+ main: boolean;
57
+ /** The absolute path of the current module.
58
+ *
59
+ * This property is only provided for local modules (ie. using `file://` URLs).
60
+ *
61
+ * Example:
62
+ * ```
63
+ * // Unix
64
+ * console.log(import.meta.filename); // /home/alice/my_module.ts
65
+ *
66
+ * // Windows
67
+ * console.log(import.meta.filename); // C:\alice\my_module.ts
68
+ * ```
69
+ */
70
+ filename: string;
71
+ /** The absolute path of the directory containing the current module.
72
+ *
73
+ * This property is only provided for local modules (ie. using `file://` URLs).
74
+ *
75
+ * * Example:
76
+ * ```
77
+ * // Unix
78
+ * console.log(import.meta.dirname); // /home/alice
79
+ *
80
+ * // Windows
81
+ * console.log(import.meta.dirname); // C:\alice
82
+ * ```
83
+ */
84
+ dirname: string;
85
+ }
86
+ }
87
+ type NodeRequest = ReturnType<typeof createRequire>;
88
+ type NodeModule = NonNullable<NodeRequest["main"]>;
89
+ interface ImportMetaPonyfillCommonjs {
90
+ (require: NodeRequest, module: NodeModule): ImportMeta;
91
+ }
92
+ interface ImportMetaPonyfillEsmodule {
93
+ (importMeta: ImportMeta): ImportMeta;
94
+ }
95
+ interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
96
+ }
97
+ export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
98
+ export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
99
+ export declare let import_meta_ponyfill: ImportMetaPonyfill;
100
+ export {};
101
+ //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
3
+ * but instead of using npm to install additional dependencies,
4
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
5
+ *
6
+ * Note that this code might be imported multiple times
7
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
8
+ * or Node.js might dynamically clear the cache and then force a require).
9
+ * Therefore, it's important to avoid redundant writes to global objects.
10
+ * Additionally, consider that commonjs is used alongside esm,
11
+ * so the two ponyfill functions are stored independently in two separate global objects.
12
+ */
13
+ //@ts-ignore
14
+ import { createRequire } from "node:module";
15
+ //@ts-ignore
16
+ import { fileURLToPath, pathToFileURL } from "node:url";
17
+ //@ts-ignore
18
+ import { dirname } from "node:path";
19
+ const defineGlobalPonyfill = (symbolFor, fn) => {
20
+ if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
21
+ Object.defineProperty(globalThis, Symbol.for(symbolFor), {
22
+ configurable: true,
23
+ get() {
24
+ return fn;
25
+ },
26
+ });
27
+ }
28
+ };
29
+ export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
30
+ (() => {
31
+ const moduleImportMetaWM = new WeakMap();
32
+ return (require, module) => {
33
+ let importMetaCache = moduleImportMetaWM.get(module);
34
+ if (importMetaCache == null) {
35
+ const importMeta = Object.assign(Object.create(null), {
36
+ url: pathToFileURL(module.filename).href,
37
+ main: require.main == module,
38
+ resolve: (specifier, parentURL = importMeta.url) => {
39
+ return pathToFileURL((importMeta.url === parentURL
40
+ ? require
41
+ : createRequire(parentURL))
42
+ .resolve(specifier)).href;
43
+ },
44
+ filename: module.filename,
45
+ dirname: module.path,
46
+ });
47
+ moduleImportMetaWM.set(module, importMeta);
48
+ importMetaCache = importMeta;
49
+ }
50
+ return importMetaCache;
51
+ };
52
+ })());
53
+ defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
54
+ export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
55
+ ((importMeta) => {
56
+ const resolveFunStr = String(importMeta.resolve);
57
+ const shimWs = new WeakSet();
58
+ //@ts-ignore
59
+ const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
60
+ .replace(/\/{3,}/, "///");
61
+ const commonShim = (importMeta) => {
62
+ if (typeof importMeta.main !== "boolean") {
63
+ importMeta.main = importMeta.url === mainUrl;
64
+ }
65
+ if (typeof importMeta.filename !== "string") {
66
+ importMeta.filename = fileURLToPath(importMeta.url);
67
+ importMeta.dirname = dirname(importMeta.filename);
68
+ }
69
+ };
70
+ if (
71
+ // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
72
+ resolveFunStr === "undefined" ||
73
+ // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
74
+ resolveFunStr.startsWith("async")
75
+ // enable by --experimental-import-meta-resolve flag
76
+ ) {
77
+ import_meta_ponyfill_esmodule = (importMeta) => {
78
+ if (!shimWs.has(importMeta)) {
79
+ shimWs.add(importMeta);
80
+ const importMetaUrlRequire = {
81
+ url: importMeta.url,
82
+ require: createRequire(importMeta.url),
83
+ };
84
+ importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
85
+ return pathToFileURL((importMetaUrlRequire.url === parentURL
86
+ ? importMetaUrlRequire.require
87
+ : createRequire(parentURL)).resolve(specifier)).href;
88
+ };
89
+ commonShim(importMeta);
90
+ }
91
+ return importMeta;
92
+ };
93
+ }
94
+ else {
95
+ /// native support
96
+ import_meta_ponyfill_esmodule = (importMeta) => {
97
+ if (!shimWs.has(importMeta)) {
98
+ shimWs.add(importMeta);
99
+ commonShim(importMeta);
100
+ }
101
+ return importMeta;
102
+ };
103
+ }
104
+ return import_meta_ponyfill_esmodule(importMeta);
105
+ }));
106
+ defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
107
+ export let import_meta_ponyfill = ((...args) => {
108
+ const _MODULE = (() => {
109
+ if (typeof require === "function" && typeof module === "object") {
110
+ return "commonjs";
111
+ }
112
+ else {
113
+ // eval("typeof import.meta");
114
+ return "esmodule";
115
+ }
116
+ })();
117
+ if (_MODULE === "commonjs") {
118
+ //@ts-ignore
119
+ import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
120
+ }
121
+ else {
122
+ //@ts-ignore
123
+ import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
124
+ }
125
+ //@ts-ignore
126
+ return import_meta_ponyfill(...args);
127
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @module compiler/inverses
3
+ *
4
+ * Inverse attribute generation — walks forward link attributes that carry
5
+ * an `inverse:` declaration and emits synthetic back-link values on target
6
+ * entries.
7
+ */
8
+ import type { Diagnostic, EffectiveProfile, Entry } from "../model/mod.js";
9
+ /** Result of inverse generation. */
10
+ export interface GenerateInversesResult {
11
+ readonly entries: readonly Entry[];
12
+ readonly diagnostics: readonly Diagnostic[];
13
+ }
14
+ /**
15
+ * Generate inverse (back-link) attributes from forward link declarations.
16
+ *
17
+ * Walks every identified entry's `typedAttributes` for attributes that match
18
+ * an `inverse:` declaration in the effective profile, then accumulates
19
+ * back-links on target entries.
20
+ */
21
+ export declare function generateInverses(entries: readonly Entry[], profile: EffectiveProfile): GenerateInversesResult;
22
+ //# sourceMappingURL=inverses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inverses.d.ts","sourceRoot":"","sources":["../../src/compiler/inverses.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,KAAK,EAEN,MAAM,iBAAiB,CAAC;AAEzB,oCAAoC;AACpC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAcD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GACxB,sBAAsB,CA4GxB"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @module compiler/inverses
3
+ *
4
+ * Inverse attribute generation — walks forward link attributes that carry
5
+ * an `inverse:` declaration and emits synthetic back-link values on target
6
+ * entries.
7
+ */
8
+ /**
9
+ * Generate inverse (back-link) attributes from forward link declarations.
10
+ *
11
+ * Walks every identified entry's `typedAttributes` for attributes that match
12
+ * an `inverse:` declaration in the effective profile, then accumulates
13
+ * back-links on target entries.
14
+ */
15
+ export function generateInverses(entries, profile) {
16
+ if (entries.length === 0) {
17
+ return { entries: [], diagnostics: [] };
18
+ }
19
+ // Step 1: Collect all inverse declarations from the profile
20
+ const inverseSpecs = collectInverseSpecs(profile);
21
+ if (inverseSpecs.length === 0) {
22
+ return { entries: [...entries], diagnostics: [] };
23
+ }
24
+ // Step 2: Index entries by id
25
+ const byId = new Map();
26
+ for (const e of entries) {
27
+ if (e.id !== undefined) {
28
+ byId.set(e.id, e);
29
+ }
30
+ }
31
+ // Step 3–5: Walk entries, accumulate back-links
32
+ // Map: targetId → Map<inverseAttrName, Set<sourceId>>
33
+ const generated = new Map();
34
+ for (const source of entries) {
35
+ if (source.shape !== "identified" || source.id === undefined)
36
+ continue;
37
+ const applicableSpecs = resolveApplicableSpecs(inverseSpecs, source.type);
38
+ for (const spec of applicableSpecs) {
39
+ const forwardValues = source.typedAttributes.get(spec.attrName);
40
+ if (!forwardValues)
41
+ continue;
42
+ for (const targetId of forwardValues) {
43
+ const target = byId.get(targetId);
44
+ if (!target || target.type !== spec.inverse.category)
45
+ continue;
46
+ let targetMap = generated.get(targetId);
47
+ if (!targetMap) {
48
+ targetMap = new Map();
49
+ generated.set(targetId, targetMap);
50
+ }
51
+ let idSet = targetMap.get(spec.inverse.name);
52
+ if (!idSet) {
53
+ idSet = new Set();
54
+ targetMap.set(spec.inverse.name, idSet);
55
+ }
56
+ idSet.add(source.id);
57
+ }
58
+ }
59
+ }
60
+ // Step 6–7: Merge generated values into entries, emit diagnostics
61
+ const diagnostics = [];
62
+ const result = [];
63
+ for (const e of entries) {
64
+ const targetInverses = e.id ? generated.get(e.id) : undefined;
65
+ if (!targetInverses) {
66
+ result.push(e);
67
+ continue;
68
+ }
69
+ const newAttrs = new Map(e.typedAttributes);
70
+ let changed = false;
71
+ for (const [inverseName, generatedIds] of targetInverses) {
72
+ const generatedArr = [...generatedIds];
73
+ const authored = e.typedAttributes.get(inverseName);
74
+ if (authored && authored.length > 0) {
75
+ const authoredSet = new Set(authored);
76
+ const genSet = generatedIds;
77
+ const match = authoredSet.size === genSet.size &&
78
+ [...authoredSet].every((v) => genSet.has(v));
79
+ if (!match) {
80
+ diagnostics.push({
81
+ code: "MSL-L005",
82
+ severity: "warning",
83
+ message: `authored "${inverseName}" on ${e.displayId} differs from generated inverse values`,
84
+ location: e.location,
85
+ });
86
+ // Union authored + generated
87
+ const union = new Set([...authored, ...generatedArr]);
88
+ newAttrs.set(inverseName, [...union]);
89
+ changed = true;
90
+ }
91
+ // If match, keep as-is
92
+ }
93
+ else {
94
+ newAttrs.set(inverseName, generatedArr);
95
+ changed = true;
96
+ }
97
+ }
98
+ if (changed) {
99
+ result.push({ ...e, typedAttributes: newAttrs });
100
+ }
101
+ else {
102
+ result.push(e);
103
+ }
104
+ }
105
+ return { entries: result, diagnostics };
106
+ }
107
+ /** Collect all inverse-bearing attribute declarations from the profile. */
108
+ function collectInverseSpecs(profile) {
109
+ const specs = [];
110
+ // Universal scope
111
+ for (const [, entry] of profile.attributes) {
112
+ if (entry.value.inverse) {
113
+ specs.push({
114
+ attrName: entry.value.name,
115
+ inverse: entry.value.inverse,
116
+ sourceType: null,
117
+ });
118
+ }
119
+ }
120
+ // Identified shape scope
121
+ for (const [, entry] of profile.identified.attributes) {
122
+ if (entry.value.inverse) {
123
+ specs.push({
124
+ attrName: entry.value.name,
125
+ inverse: entry.value.inverse,
126
+ sourceType: null,
127
+ });
128
+ }
129
+ }
130
+ // Type scopes
131
+ for (const [typeName, typeEntry] of profile.types) {
132
+ for (const [, attrEntry] of typeEntry.value.attributes) {
133
+ if (attrEntry.value.inverse) {
134
+ specs.push({
135
+ attrName: attrEntry.value.name,
136
+ inverse: attrEntry.value.inverse,
137
+ sourceType: typeName,
138
+ });
139
+ }
140
+ }
141
+ }
142
+ return specs;
143
+ }
144
+ /** Filter specs applicable to a source entry's type. */
145
+ function resolveApplicableSpecs(specs, sourceType) {
146
+ return specs.filter((s) => s.sourceType === null || s.sourceType === sourceType);
147
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module core/compiler/link_target
3
+ *
4
+ * MSL-T013: Tiered link-target severity. After links are extracted and
5
+ * inverses generated, check the state of each link target:
6
+ *
7
+ * | Target state | Severity |
8
+ * |---|---|
9
+ * | Active | OK (no diagnostic) |
10
+ * | Draft (Labels: DRAFT) | info |
11
+ * | Retired (Superseded-by: set OR Deprecated: set) | warning |
12
+ */
13
+ import type { Diagnostic, DisplayId, Entry, Link } from "../model/mod.js";
14
+ /**
15
+ * Check all link targets for retirement/draft state.
16
+ * Run after inverse generation so `Superseded-by:` is available.
17
+ */
18
+ export declare function checkLinkTargets(entries: ReadonlyMap<DisplayId, Entry>, links: readonly Link[]): Diagnostic[];
19
+ //# sourceMappingURL=link_target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link_target.d.ts","sourceRoot":"","sources":["../../src/compiler/link_target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE1E;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,EACtC,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,UAAU,EAAE,CA4Bd"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @module core/compiler/link_target
3
+ *
4
+ * MSL-T013: Tiered link-target severity. After links are extracted and
5
+ * inverses generated, check the state of each link target:
6
+ *
7
+ * | Target state | Severity |
8
+ * |---|---|
9
+ * | Active | OK (no diagnostic) |
10
+ * | Draft (Labels: DRAFT) | info |
11
+ * | Retired (Superseded-by: set OR Deprecated: set) | warning |
12
+ */
13
+ /**
14
+ * Check all link targets for retirement/draft state.
15
+ * Run after inverse generation so `Superseded-by:` is available.
16
+ */
17
+ export function checkLinkTargets(entries, links) {
18
+ const diagnostics = [];
19
+ for (const link of links) {
20
+ const target = entries.get(link.to);
21
+ if (!target)
22
+ continue; // Unresolved — handled by MSL-T005/MSL-T012
23
+ const state = classifyTargetState(target);
24
+ if (state === "active")
25
+ continue;
26
+ if (state === "draft") {
27
+ diagnostics.push({
28
+ code: "MSL-T013",
29
+ severity: "info",
30
+ message: `${link.from}: link target '${link.to}' is marked DRAFT`,
31
+ location: link.location,
32
+ });
33
+ }
34
+ else {
35
+ diagnostics.push({
36
+ code: "MSL-T013",
37
+ severity: "warning",
38
+ message: `${link.from}: link target '${link.to}' is retired`,
39
+ location: link.location,
40
+ });
41
+ }
42
+ }
43
+ return diagnostics;
44
+ }
45
+ function classifyTargetState(entry) {
46
+ // Check for retirement markers
47
+ const hasDeprecated = entry.rawAttributes.some((a) => a.key === "Deprecated");
48
+ if (hasDeprecated)
49
+ return "retired";
50
+ const supersededBy = entry.typedAttributes.get("Superseded-by");
51
+ if (supersededBy && supersededBy.length > 0)
52
+ return "retired";
53
+ // Check for DRAFT label via typedAttributes
54
+ const labels = entry.typedAttributes.get("Labels");
55
+ if (labels && labels.includes("DRAFT"))
56
+ return "draft";
57
+ // Also check raw attributes for Labels containing DRAFT
58
+ for (const attr of entry.rawAttributes) {
59
+ if (attr.key === "Labels") {
60
+ const values = attr.value.split(",").map((s) => s.trim());
61
+ if (values.includes("DRAFT"))
62
+ return "draft";
63
+ }
64
+ }
65
+ return "active";
66
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module compiler
3
+ *
4
+ * Compiler pipeline. Takes file paths, parses all entries, validates them,
5
+ * builds a bidirectional traceability graph, and returns the compiled model.
6
+ */
7
+ import type { Diagnostic, DisplayId, Document, EffectiveProfile, Entry, Link } from "../model/mod.js";
8
+ /** Options for {@linkcode compile}. */
9
+ export interface CompileOptions {
10
+ /** File reader function. Required — no default to avoid Deno dependency in library code. */
11
+ readonly readFile: (path: string) => Promise<string>;
12
+ /** Active profile for inverse attribute generation. Optional — when absent, inverses are skipped. */
13
+ readonly profile?: EffectiveProfile;
14
+ }
15
+ /** Compiled project output with resolved traceability graph. */
16
+ export interface CompileResult {
17
+ /** All entries keyed by display ID. */
18
+ readonly entries: ReadonlyMap<DisplayId, Entry>;
19
+ /** All traceability links. */
20
+ readonly links: readonly Link[];
21
+ /** Outgoing links per entry (entry → targets). */
22
+ readonly forward: ReadonlyMap<DisplayId, readonly Link[]>;
23
+ /** Incoming links per entry (entry → sources pointing to it). */
24
+ readonly reverse: ReadonlyMap<DisplayId, readonly Link[]>;
25
+ /** Documents keyed by file path. A file appears here only when it carried YAML front matter per ADR-007. */
26
+ readonly documents: ReadonlyMap<string, Document>;
27
+ /** Diagnostics from parsing and validation. */
28
+ readonly diagnostics: readonly Diagnostic[];
29
+ }
30
+ /**
31
+ * Compile MarkSpec files from the given paths into a resolved
32
+ * traceability graph.
33
+ *
34
+ * @param paths - File paths to compile
35
+ * @param options - Compile options
36
+ * @returns Compiled entries, links, and diagnostics
37
+ */
38
+ export declare function compile(paths: readonly string[], options: CompileOptions): Promise<CompileResult>;
39
+ export { serializeCompileResult } from "./schema.js";
40
+ export type { SerializedCompileResult } from "./schema.js";
41
+ export { generateInverses } from "./inverses.js";
42
+ export type { GenerateInversesResult } from "./inverses.js";
43
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,IAAI,EAGL,MAAM,iBAAiB,CAAC;AAMzB,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,qGAAqG;IACrG,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChD,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAC1D,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAC1D,4GAA4G;IAC5G,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CA4ExB;AAmGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}