@dxos/deus 0.0.0-stage → 0.0.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 (201) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +24 -2
  3. package/bin/deus.ts +42 -0
  4. package/dist/lib/chunk-blocks.mjs +151 -0
  5. package/dist/lib/chunk-blocks.mjs.map +1 -0
  6. package/dist/lib/chunk-check.mjs +452 -0
  7. package/dist/lib/chunk-check.mjs.map +1 -0
  8. package/dist/lib/chunk-completion.mjs +112 -0
  9. package/dist/lib/chunk-completion.mjs.map +1 -0
  10. package/dist/lib/chunk-extension.mjs +396 -0
  11. package/dist/lib/chunk-extension.mjs.map +1 -0
  12. package/dist/lib/chunk-parse.mjs +21 -0
  13. package/dist/lib/chunk-parse.mjs.map +1 -0
  14. package/dist/lib/cli.mjs +946 -0
  15. package/dist/lib/cli.mjs.map +1 -0
  16. package/dist/lib/extension.mjs +4 -0
  17. package/dist/lib/index.mjs +6 -0
  18. package/dist/lib/parse.mjs +4 -0
  19. package/dist/lib/review.mjs +260 -0
  20. package/dist/lib/review.mjs.map +1 -0
  21. package/dist/lib/spec-index.mjs +28 -0
  22. package/dist/lib/spec-index.mjs.map +1 -0
  23. package/dist/types/bin/deus.d.ts +3 -0
  24. package/dist/types/bin/deus.d.ts.map +1 -0
  25. package/dist/types/src/cli/__fixtures__/review/plugin-deps/dx.config.d.ts +8 -0
  26. package/dist/types/src/cli/__fixtures__/review/plugin-deps/dx.config.d.ts.map +1 -0
  27. package/dist/types/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.d.ts +8 -0
  28. package/dist/types/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.d.ts.map +1 -0
  29. package/dist/types/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.d.ts +7 -0
  30. package/dist/types/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.d.ts.map +1 -0
  31. package/dist/types/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.d.ts +8 -0
  32. package/dist/types/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.d.ts.map +1 -0
  33. package/dist/types/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.d.ts +5 -0
  34. package/dist/types/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.d.ts.map +1 -0
  35. package/dist/types/src/cli/changelog.d.ts +25 -0
  36. package/dist/types/src/cli/changelog.d.ts.map +1 -0
  37. package/dist/types/src/cli/cli.test.d.ts +2 -0
  38. package/dist/types/src/cli/cli.test.d.ts.map +1 -0
  39. package/dist/types/src/cli/errors.d.ts +183 -0
  40. package/dist/types/src/cli/errors.d.ts.map +1 -0
  41. package/dist/types/src/cli/features.d.ts +58 -0
  42. package/dist/types/src/cli/features.d.ts.map +1 -0
  43. package/dist/types/src/cli/git.d.ts +8 -0
  44. package/dist/types/src/cli/git.d.ts.map +1 -0
  45. package/dist/types/src/cli/index.d.ts +12 -0
  46. package/dist/types/src/cli/index.d.ts.map +1 -0
  47. package/dist/types/src/cli/lint.d.ts +17 -0
  48. package/dist/types/src/cli/lint.d.ts.map +1 -0
  49. package/dist/types/src/cli/qa-lint.d.ts +40 -0
  50. package/dist/types/src/cli/qa-lint.d.ts.map +1 -0
  51. package/dist/types/src/cli/qa.d.ts +86 -0
  52. package/dist/types/src/cli/qa.d.ts.map +1 -0
  53. package/dist/types/src/cli/review.d.ts +38 -0
  54. package/dist/types/src/cli/review.d.ts.map +1 -0
  55. package/dist/types/src/cli/spec-index.d.ts +17 -0
  56. package/dist/types/src/cli/spec-index.d.ts.map +1 -0
  57. package/dist/types/src/extension/blocks.d.ts +65 -0
  58. package/dist/types/src/extension/blocks.d.ts.map +1 -0
  59. package/dist/types/src/extension/check.d.ts +99 -0
  60. package/dist/types/src/extension/check.d.ts.map +1 -0
  61. package/dist/types/src/extension/check.test.d.ts +2 -0
  62. package/dist/types/src/extension/check.test.d.ts.map +1 -0
  63. package/dist/types/src/extension/code.d.ts +7 -0
  64. package/dist/types/src/extension/code.d.ts.map +1 -0
  65. package/dist/types/src/extension/complete.d.ts +6 -0
  66. package/dist/types/src/extension/complete.d.ts.map +1 -0
  67. package/dist/types/src/extension/completion.d.ts +10 -0
  68. package/dist/types/src/extension/completion.d.ts.map +1 -0
  69. package/dist/types/src/extension/constants.d.ts +6 -0
  70. package/dist/types/src/extension/constants.d.ts.map +1 -0
  71. package/dist/types/src/extension/fences.d.ts +10 -0
  72. package/dist/types/src/extension/fences.d.ts.map +1 -0
  73. package/dist/types/src/extension/gen/mdl.d.ts +3 -0
  74. package/dist/types/src/extension/gen/mdl.d.ts.map +1 -0
  75. package/dist/types/src/extension/gen/mdl.terms.d.ts +2 -0
  76. package/dist/types/src/extension/gen/mdl.terms.d.ts.map +1 -0
  77. package/dist/types/src/extension/index.d.ts +8 -0
  78. package/dist/types/src/extension/index.d.ts.map +1 -0
  79. package/dist/types/src/extension/language.d.ts +20 -0
  80. package/dist/types/src/extension/language.d.ts.map +1 -0
  81. package/dist/types/src/extension/lint.d.ts +8 -0
  82. package/dist/types/src/extension/lint.d.ts.map +1 -0
  83. package/dist/types/src/extension/parse.d.ts +6 -0
  84. package/dist/types/src/extension/parse.d.ts.map +1 -0
  85. package/dist/types/src/extension/parser.test.d.ts +2 -0
  86. package/dist/types/src/extension/parser.test.d.ts.map +1 -0
  87. package/dist/types/src/extension/refs.d.ts +32 -0
  88. package/dist/types/src/extension/refs.d.ts.map +1 -0
  89. package/dist/types/src/extension/refs.test.d.ts +2 -0
  90. package/dist/types/src/extension/refs.test.d.ts.map +1 -0
  91. package/dist/types/src/extension/syntax.d.ts +12 -0
  92. package/dist/types/src/extension/syntax.d.ts.map +1 -0
  93. package/dist/types/src/index.d.ts +3 -0
  94. package/dist/types/src/index.d.ts.map +1 -0
  95. package/dist/types/src/review/fields.d.ts +9 -0
  96. package/dist/types/src/review/fields.d.ts.map +1 -0
  97. package/dist/types/src/review/index.d.ts +5 -0
  98. package/dist/types/src/review/index.d.ts.map +1 -0
  99. package/dist/types/src/review/review.d.ts +70 -0
  100. package/dist/types/src/review/review.d.ts.map +1 -0
  101. package/dist/types/src/review/review.test.d.ts +2 -0
  102. package/dist/types/src/review/review.test.d.ts.map +1 -0
  103. package/dist/types/src/review/source-key.d.ts +35 -0
  104. package/dist/types/src/review/source-key.d.ts.map +1 -0
  105. package/dist/types/src/review/symbol.d.ts +17 -0
  106. package/dist/types/src/review/symbol.d.ts.map +1 -0
  107. package/dist/types/src/review/symbol.test.d.ts +2 -0
  108. package/dist/types/src/review/symbol.test.d.ts.map +1 -0
  109. package/dist/types/src/spec-index/index.d.ts +3 -0
  110. package/dist/types/src/spec-index/index.d.ts.map +1 -0
  111. package/dist/types/src/spec-index/parse.d.ts +11 -0
  112. package/dist/types/src/spec-index/parse.d.ts.map +1 -0
  113. package/dist/types/src/spec-index/spec-index.d.ts +21 -0
  114. package/dist/types/src/spec-index/spec-index.d.ts.map +1 -0
  115. package/dist/types/src/spec-index/spec-index.test.d.ts +2 -0
  116. package/dist/types/src/spec-index/spec-index.test.d.ts.map +1 -0
  117. package/dist/types/tsconfig.tsbuildinfo +1 -0
  118. package/docs/DESIGN.md +561 -0
  119. package/docs/IDIOMS.md +265 -0
  120. package/lang/PLUGIN-.template.mdl +115 -0
  121. package/lang/app.mdl +200 -0
  122. package/lang/changelog.mdl +184 -0
  123. package/lang/core.mdl +203 -0
  124. package/lang/examples/chess-1.mdl +149 -0
  125. package/lang/examples/chess-2.mdl +203 -0
  126. package/lang/examples/chess-3.mdl +231 -0
  127. package/lang/features.mdl +92 -0
  128. package/lang/plugin.mdl +59 -0
  129. package/lang/qa.mdl +383 -0
  130. package/lang/review.mdl +103 -0
  131. package/lang/sql.mdl +72 -0
  132. package/package.json +74 -3
  133. package/src/cli/__fixtures__/bad-decision.mdl +13 -0
  134. package/src/cli/__fixtures__/features/CYCLE.mdl +25 -0
  135. package/src/cli/__fixtures__/features/FEATURES.mdl +47 -0
  136. package/src/cli/__fixtures__/features/SPEC.mdl +22 -0
  137. package/src/cli/__fixtures__/features/SPEC.review.mdl +32 -0
  138. package/src/cli/__fixtures__/features/TASKS.md +5 -0
  139. package/src/cli/__fixtures__/lint-refs/SPEC.mdl +7 -0
  140. package/src/cli/__fixtures__/lint-refs/SPEC.review.mdl +7 -0
  141. package/src/cli/__fixtures__/qa-lint/packages/plugins/plugin-risky/PLUGIN.mdl +29 -0
  142. package/src/cli/__fixtures__/qa-list/plugin-sample/spec/PLUGIN.mdl +51 -0
  143. package/src/cli/__fixtures__/review/SPEC.mdl +23 -0
  144. package/src/cli/__fixtures__/review/SPEC.review.mdl +26 -0
  145. package/src/cli/__fixtures__/review/plugin-deps/PLUGIN.mdl +9 -0
  146. package/src/cli/__fixtures__/review/plugin-deps/PLUGIN.review.mdl +13 -0
  147. package/src/cli/__fixtures__/review/plugin-deps/dx.config.ts +10 -0
  148. package/src/cli/__fixtures__/review/plugin-deps-diverged/PLUGIN.mdl +9 -0
  149. package/src/cli/__fixtures__/review/plugin-deps-diverged/PLUGIN.review.mdl +14 -0
  150. package/src/cli/__fixtures__/review/plugin-deps-diverged/dx.config.ts +10 -0
  151. package/src/cli/__fixtures__/review/plugin-deps-empty/PLUGIN.mdl +9 -0
  152. package/src/cli/__fixtures__/review/plugin-deps-empty/PLUGIN.review.mdl +13 -0
  153. package/src/cli/__fixtures__/review/plugin-deps-empty/dx.config.ts +9 -0
  154. package/src/cli/__fixtures__/review/plugin-deps-mismatch/PLUGIN.mdl +9 -0
  155. package/src/cli/__fixtures__/review/plugin-deps-mismatch/PLUGIN.review.mdl +13 -0
  156. package/src/cli/__fixtures__/review/plugin-deps-mismatch/dx.config.ts +10 -0
  157. package/src/cli/__fixtures__/review/plugin-deps-noplugin/PLUGIN.mdl +9 -0
  158. package/src/cli/__fixtures__/review/plugin-deps-noplugin/PLUGIN.review.mdl +13 -0
  159. package/src/cli/__fixtures__/review/plugin-deps-noplugin/dx.config.ts +7 -0
  160. package/src/cli/changelog.ts +122 -0
  161. package/src/cli/cli.test.ts +359 -0
  162. package/src/cli/errors.ts +23 -0
  163. package/src/cli/features.ts +320 -0
  164. package/src/cli/git.ts +35 -0
  165. package/src/cli/index.ts +27 -0
  166. package/src/cli/lint.ts +75 -0
  167. package/src/cli/qa-lint.ts +206 -0
  168. package/src/cli/qa.ts +300 -0
  169. package/src/cli/review.ts +359 -0
  170. package/src/cli/spec-index.ts +54 -0
  171. package/src/extension/blocks.ts +169 -0
  172. package/src/extension/check.test.ts +629 -0
  173. package/src/extension/check.ts +552 -0
  174. package/src/extension/code.ts +99 -0
  175. package/src/extension/complete.ts +34 -0
  176. package/src/extension/completion.ts +64 -0
  177. package/src/extension/constants.ts +28 -0
  178. package/src/extension/fences.ts +270 -0
  179. package/src/extension/gen/mdl.terms.ts +16 -0
  180. package/src/extension/gen/mdl.ts +16 -0
  181. package/src/extension/index.ts +25 -0
  182. package/src/extension/language.ts +33 -0
  183. package/src/extension/lint.ts +19 -0
  184. package/src/extension/mdl.grammar +60 -0
  185. package/src/extension/parse.ts +31 -0
  186. package/src/extension/parser.test.ts +248 -0
  187. package/src/extension/refs.test.ts +95 -0
  188. package/src/extension/refs.ts +94 -0
  189. package/src/extension/syntax.ts +25 -0
  190. package/src/index.ts +6 -0
  191. package/src/review/fields.ts +31 -0
  192. package/src/review/index.ts +8 -0
  193. package/src/review/review.test.ts +111 -0
  194. package/src/review/review.ts +184 -0
  195. package/src/review/source-key.ts +63 -0
  196. package/src/review/symbol.test.ts +47 -0
  197. package/src/review/symbol.ts +96 -0
  198. package/src/spec-index/index.ts +6 -0
  199. package/src/spec-index/parse.ts +22 -0
  200. package/src/spec-index/spec-index.test.ts +56 -0
  201. package/src/spec-index/spec-index.ts +49 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-completion.mjs","names":[],"sources":["../../src/extension/completion.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { FENCE_REGEX } from './blocks.ts';\n\n// Standard fields for each block type.\n// In future this will be derived from resolved `ext` definitions.\nexport const BLOCK_FIELDS: Record<string, string[]> = {\n ext: ['uri', 'desc', 'extends', 'fields', 'adds-fields', 'nesting', 'inline-prose', 'example'],\n type: ['desc', 'fields', 'literals', 'extends'],\n op: ['desc', 'input', 'output', 'errors', 'effects', 'requires', 'invariants', 'note'],\n feat: ['desc', 'req'],\n test: ['given', 'when', 'then', 'tags'],\n component: ['desc', 'props', 'state', 'slots', 'actions', 'emits', 'layout'],\n service: ['desc', 'loading', 'ops', 'errors', 'note'],\n db: ['desc', 'backend', 'entities', 'queries', 'note'],\n module: ['desc', 'api', 'styleguide'],\n decision: ['date', 'by', 'for', 'affects', 'supersedes', 'answers', 'why', 'rejected', 'source'],\n question: ['date', 'by', 'for', 'affects', 'context', 'options', 'source'],\n};\n\n/**\n * The fields a cursor at `pos` may complete: inside an `mdl` fence, past its header line, before any `:` on the line.\n * Undefined anywhere else, or in a block whose type has no known fields.\n */\nexport const fieldCompletionContext = (\n text: string,\n pos: number,\n): { blockType: string; fields: string[] } | undefined => {\n const before = text.slice(0, pos);\n\n // Find the innermost open ```mdl fence above the cursor.\n const openFences = [...before.matchAll(new RegExp(FENCE_REGEX.source, FENCE_REGEX.flags))];\n const closeFences = [...before.matchAll(/^```\\s*$/gm)];\n if (openFences.length === 0 || openFences.length <= closeFences.length) {\n return undefined;\n }\n\n const lastOpen = openFences[openFences.length - 1];\n const fenceEnd = lastOpen.index + lastOpen[0].length;\n\n // Read block type from the first body line (immediately after the fence header).\n const newlineAfterFence = text.indexOf('\\n', fenceEnd);\n if (newlineAfterFence === -1) {\n return undefined;\n }\n const firstBodyStart = newlineAfterFence + 1;\n const firstBodyEnd = text.indexOf('\\n', firstBodyStart);\n const firstBodyLine = (\n firstBodyEnd === -1 ? text.slice(firstBodyStart) : text.slice(firstBodyStart, firstBodyEnd)\n ).trim();\n const blockType = firstBodyLine.match(/^(\\w+)/)?.[1] ?? '';\n\n const fields = BLOCK_FIELDS[blockType];\n // The header line names the block type itself, so it takes no field.\n if (!fields || firstBodyEnd === -1 || pos <= firstBodyEnd) {\n return undefined;\n }\n\n // Only complete at the start of a line (field name position).\n const partial = before.slice(before.lastIndexOf('\\n') + 1);\n return partial.includes(':') ? undefined : { blockType, fields };\n};\n"],"mappings":";;AAQA,IAAa,eAAyC;CACpD,KAAK;EAAC;EAAO;EAAQ;EAAW;EAAU;EAAe;EAAW;EAAgB;CAAS;CAC7F,MAAM;EAAC;EAAQ;EAAU;EAAY;CAAS;CAC9C,IAAI;EAAC;EAAQ;EAAS;EAAU;EAAU;EAAW;EAAY;EAAc;CAAM;CACrF,MAAM,CAAC,QAAQ,KAAK;CACpB,MAAM;EAAC;EAAS;EAAQ;EAAQ;CAAM;CACtC,WAAW;EAAC;EAAQ;EAAS;EAAS;EAAS;EAAW;EAAS;CAAQ;CAC3E,SAAS;EAAC;EAAQ;EAAW;EAAO;EAAU;CAAM;CACpD,IAAI;EAAC;EAAQ;EAAW;EAAY;EAAW;CAAM;CACrD,QAAQ;EAAC;EAAQ;EAAO;CAAY;CACpC,UAAU;EAAC;EAAQ;EAAM;EAAO;EAAW;EAAc;EAAW;EAAO;EAAY;CAAQ;CAC/F,UAAU;EAAC;EAAQ;EAAM;EAAO;EAAW;EAAW;EAAW;CAAQ;AAC3E;;;;;AAMA,IAAa,0BACX,MACA,QACwD;CACxD,MAAM,SAAS,KAAK,MAAM,GAAG,GAAG;CAGhC,MAAM,aAAa,CAAC,GAAG,OAAO,SAAS,IAAI,OAAO,YAAY,QAAQ,YAAY,KAAK,CAAC,CAAC;CACzF,MAAM,cAAc,CAAC,GAAG,OAAO,SAAS,YAAY,CAAC;CACrD,IAAI,WAAW,WAAW,KAAK,WAAW,UAAU,YAAY,QAC9D;CAGF,MAAM,WAAW,WAAW,WAAW,SAAS;CAChD,MAAM,WAAW,SAAS,QAAQ,SAAS,EAAE,CAAC;CAG9C,MAAM,oBAAoB,KAAK,QAAQ,MAAM,QAAQ;CACrD,IAAI,sBAAsB,IACxB;CAEF,MAAM,iBAAiB,oBAAoB;CAC3C,MAAM,eAAe,KAAK,QAAQ,MAAM,cAAc;CAItD,MAAM,aAFJ,iBAAiB,KAAK,KAAK,MAAM,cAAc,IAAI,KAAK,MAAM,gBAAgB,YAAY,EAAA,CAC1F,KACgB,CAAA,CAAc,MAAM,QAAQ,CAAC,GAAG,MAAM;CAExD,MAAM,SAAS,aAAa;CAE5B,IAAI,CAAC,UAAU,iBAAiB,MAAM,OAAO,cAC3C;CAKF,OADgB,OAAO,MAAM,OAAO,YAAY,IAAI,IAAI,CACjD,CAAA,CAAQ,SAAS,GAAG,IAAI,KAAA,IAAY;EAAE;EAAW;CAAO;AACjE"}
@@ -0,0 +1,396 @@
1
+ import { a as lintMdl } from "./chunk-check.mjs";
2
+ import { n as fieldCompletionContext } from "./chunk-completion.mjs";
3
+ import { LRLanguage, LanguageDescription, LanguageSupport, syntaxTree } from "@codemirror/language";
4
+ import { RangeSetBuilder } from "@codemirror/state";
5
+ import { Decoration, EditorView, ViewPlugin } from "@codemirror/view";
6
+ import { highlightTree, tagHighlighter, tags } from "@lezer/highlight";
7
+ import { linter } from "@codemirror/lint";
8
+ import { LRParser } from "@lezer/lr";
9
+ import { autocompletion } from "@codemirror/autocomplete";
10
+ //#region \0rolldown/runtime.js
11
+ var __defProp = Object.defineProperty;
12
+ var __exportAll = (all, no_symbols) => {
13
+ let target = {};
14
+ for (var name in all) __defProp(target, name, {
15
+ get: all[name],
16
+ enumerable: true
17
+ });
18
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return target;
20
+ };
21
+ //#endregion
22
+ //#region src/extension/code.ts
23
+ /** Fences that other extensions colour, or that have no nested language. */
24
+ var SKIPPED_FENCES = /* @__PURE__ */ new Set([
25
+ "",
26
+ "mdl",
27
+ "diagram",
28
+ "mermaid"
29
+ ]);
30
+ var highlighter = tagHighlighter([
31
+ {
32
+ tag: [
33
+ tags.keyword,
34
+ tags.controlKeyword,
35
+ tags.definitionKeyword,
36
+ tags.moduleKeyword,
37
+ tags.operatorKeyword,
38
+ tags.modifier
39
+ ],
40
+ class: "cm-code-keyword"
41
+ },
42
+ {
43
+ tag: [
44
+ tags.string,
45
+ tags.special(tags.string),
46
+ tags.regexp,
47
+ tags.escape
48
+ ],
49
+ class: "cm-code-string"
50
+ },
51
+ {
52
+ tag: [
53
+ tags.number,
54
+ tags.bool,
55
+ tags.null,
56
+ tags.atom
57
+ ],
58
+ class: "cm-code-literal"
59
+ },
60
+ {
61
+ tag: [
62
+ tags.comment,
63
+ tags.lineComment,
64
+ tags.blockComment,
65
+ tags.docComment
66
+ ],
67
+ class: "cm-code-comment"
68
+ },
69
+ {
70
+ tag: [
71
+ tags.typeName,
72
+ tags.className,
73
+ tags.namespace
74
+ ],
75
+ class: "cm-code-type"
76
+ },
77
+ {
78
+ tag: [tags.function(tags.variableName), tags.function(tags.propertyName)],
79
+ class: "cm-code-function"
80
+ },
81
+ {
82
+ tag: [tags.propertyName, tags.definition(tags.propertyName)],
83
+ class: "cm-code-property"
84
+ }
85
+ ]);
86
+ var theme$1 = EditorView.baseTheme({
87
+ ".cm-code-keyword": { color: "var(--color-violet-400)" },
88
+ ".cm-code-string": { color: "var(--color-emerald-400)" },
89
+ ".cm-code-literal": { color: "var(--color-orange-400)" },
90
+ ".cm-code-comment": {
91
+ color: "var(--color-slate-400)",
92
+ fontStyle: "italic"
93
+ },
94
+ ".cm-code-type": { color: "var(--color-sky-400)" },
95
+ ".cm-code-function": { color: "var(--color-amber-400)" },
96
+ ".cm-code-property": { color: "var(--color-blue-400)" }
97
+ });
98
+ var fenceLanguage = (state, from, to) => state.sliceDoc(from, to).trim().split(/\s/)[0].toLowerCase();
99
+ var buildDecorations$1 = (view) => {
100
+ const builder = new RangeSetBuilder();
101
+ const tree = syntaxTree(view.state);
102
+ for (const { from, to } of view.visibleRanges) tree.iterate({
103
+ from,
104
+ to,
105
+ enter: (node) => {
106
+ if (node.name !== "FencedCode") return;
107
+ const info = node.node.getChild("CodeInfo");
108
+ const text = node.node.getChild("CodeText");
109
+ if (text && !SKIPPED_FENCES.has(info ? fenceLanguage(view.state, info.from, info.to) : "")) highlightTree(tree, highlighter, (start, end, cls) => builder.add(start, end, Decoration.mark({ class: cls })), Math.max(text.from, from), Math.min(text.to, to));
110
+ return false;
111
+ }
112
+ });
113
+ return builder.finish();
114
+ };
115
+ /**
116
+ * Colours the fenced code of other languages (`ts`, `sql`, …) in a spec, whose tokens the markdown
117
+ * highlight style leaves uncoloured.
118
+ */
119
+ var codeFenceHighlight = [theme$1, ViewPlugin.fromClass(class {
120
+ decorations;
121
+ constructor(view) {
122
+ this.decorations = buildDecorations$1(view);
123
+ }
124
+ update(update) {
125
+ if (update.docChanged || update.viewportChanged || syntaxTree(update.startState) !== syntaxTree(update.state)) this.decorations = buildDecorations$1(update.view);
126
+ }
127
+ }, { decorations: (plugin) => plugin.decorations })];
128
+ //#endregion
129
+ //#region src/extension/fences.ts
130
+ var BLOCK_TYPE_COLORS = {
131
+ ext: "var(--color-violet-400)",
132
+ type: "var(--color-blue-400)",
133
+ op: "var(--color-orange-400)",
134
+ feat: "var(--color-emerald-400)",
135
+ feature: "var(--color-sky-400)",
136
+ scenario: "var(--color-cyan-400)",
137
+ test: "var(--color-teal-400)",
138
+ component: "var(--color-pink-400)",
139
+ service: "var(--color-yellow-400)",
140
+ db: "var(--color-red-400)",
141
+ module: "var(--color-indigo-400)",
142
+ suite: "var(--color-lime-400)",
143
+ decision: "var(--color-amber-400)",
144
+ question: "var(--color-orange-300)",
145
+ verdict: "var(--color-green-400)",
146
+ plugin: "var(--color-fuchsia-400)",
147
+ uses: "var(--color-rose-400)",
148
+ table: "var(--color-red-400)"
149
+ };
150
+ var theme = EditorView.baseTheme({
151
+ ".cm-mdl-fence-tick": { color: "var(--color-slate-400)" },
152
+ ".cm-mdl-block-id": { color: "var(--color-orange-400)" },
153
+ ".cm-mdl-block-header": { color: "var(--color-pink-400)" },
154
+ ".cm-mdl-field": { color: "var(--color-blue-400)" },
155
+ ".cm-mdl-punct": { color: "var(--color-slate-400)" },
156
+ ".cm-mdl-comment": {
157
+ color: "var(--color-green-400)",
158
+ fontStyle: "italic"
159
+ },
160
+ ...Object.fromEntries(Object.entries(BLOCK_TYPE_COLORS).map(([type, color]) => [`& .cm-mdl-block-${type}`, { color }]))
161
+ });
162
+ /** Color a single line of the block body using regex matching. */
163
+ var decorateLine = (builder, lineText, lineFrom) => {
164
+ const trimmed = lineText.trimStart();
165
+ const indent = lineText.length - trimmed.length;
166
+ const abs = (offset) => lineFrom + offset;
167
+ if (trimmed.startsWith("#")) {
168
+ builder.add(abs(indent), abs(lineText.length), Decoration.mark({ class: "cm-mdl-comment" }));
169
+ return;
170
+ }
171
+ const lineMatch = trimmed.match(/^([\w][\w-]*)(?:\s+([\w][\w.-]*))?(\??)(\s*:)(.*)/s);
172
+ if (!lineMatch) {
173
+ const commentIdx = lineText.indexOf(" #", indent);
174
+ if (commentIdx >= 0) builder.add(abs(commentIdx + 1), abs(lineText.length), Decoration.mark({ class: "cm-mdl-comment" }));
175
+ return;
176
+ }
177
+ const [, fieldName, id, optMarker, colonPart] = lineMatch;
178
+ const fieldFrom = abs(indent);
179
+ const fieldTo = fieldFrom + fieldName.length;
180
+ builder.add(fieldFrom, fieldTo, Decoration.mark({ class: "cm-mdl-field" }));
181
+ let pos = indent + fieldName.length;
182
+ if (id) {
183
+ const idFrom = abs(pos + 1);
184
+ const idTo = idFrom + id.length;
185
+ builder.add(idFrom, idTo, Decoration.mark({ class: "cm-mdl-block-id" }));
186
+ pos += 1 + id.length;
187
+ }
188
+ if (optMarker) {
189
+ builder.add(abs(pos), abs(pos + 1), Decoration.mark({ class: "cm-mdl-punct" }));
190
+ pos += 1;
191
+ }
192
+ const colonPos = pos + colonPart.length - 1;
193
+ builder.add(abs(colonPos), abs(colonPos + 1), Decoration.mark({ class: "cm-mdl-punct" }));
194
+ pos += colonPart.length;
195
+ const commentOffset = lineText.indexOf(" #", pos);
196
+ const valueEnd = commentOffset >= 0 ? commentOffset : lineText.length;
197
+ const valueStart = pos;
198
+ const valuePart = lineText.slice(valueStart, valueEnd);
199
+ const bracketMatch = valuePart.match(/^\s*\[([^\]]*)\]/);
200
+ if (bracketMatch) {
201
+ const openIdx = valueStart + valuePart.indexOf("[");
202
+ const closeIdx = valueStart + valuePart.indexOf("]");
203
+ builder.add(abs(openIdx), abs(openIdx + 1), Decoration.mark({ class: "cm-mdl-punct" }));
204
+ const inner = bracketMatch[1];
205
+ const tokenRe = /(\w[\w-]*)|,/g;
206
+ let token;
207
+ while ((token = tokenRe.exec(inner)) !== null) {
208
+ const tokenFrom = openIdx + 1 + token.index;
209
+ if (token[1]) builder.add(abs(tokenFrom), abs(tokenFrom + token[0].length), Decoration.mark({ class: "cm-mdl-block-id" }));
210
+ else builder.add(abs(tokenFrom), abs(tokenFrom + 1), Decoration.mark({ class: "cm-mdl-punct" }));
211
+ }
212
+ builder.add(abs(closeIdx), abs(closeIdx + 1), Decoration.mark({ class: "cm-mdl-punct" }));
213
+ }
214
+ let pipeIdx = valuePart.indexOf("|");
215
+ while (pipeIdx >= 0) {
216
+ const absIdx = valueStart + pipeIdx;
217
+ builder.add(abs(absIdx), abs(absIdx + 1), Decoration.mark({ class: "cm-mdl-punct" }));
218
+ pipeIdx = valuePart.indexOf("|", pipeIdx + 1);
219
+ }
220
+ if (commentOffset >= 0) builder.add(abs(commentOffset + 1), abs(lineText.length), Decoration.mark({ class: "cm-mdl-comment" }));
221
+ };
222
+ var buildDecorations = (view) => {
223
+ const builder = new RangeSetBuilder();
224
+ const { state } = view;
225
+ const fmMatch = state.doc.toString().match(/^---\n([\s\S]*?\n)---(?:\n|$)/);
226
+ if (fmMatch) {
227
+ builder.add(0, 3, Decoration.mark({ class: "cm-mdl-fence-tick" }));
228
+ const fmContent = fmMatch[1];
229
+ let lineOffset = 4;
230
+ for (const line of fmContent.split("\n")) {
231
+ if (line.trim()) decorateLine(builder, line, lineOffset);
232
+ lineOffset += line.length + 1;
233
+ }
234
+ const closeFrom = 4 + fmMatch[1].length;
235
+ builder.add(closeFrom, closeFrom + 3, Decoration.mark({ class: "cm-mdl-fence-tick" }));
236
+ }
237
+ syntaxTree(state).iterate({ enter(node) {
238
+ if (node.name !== "CodeInfo") return;
239
+ if (state.doc.sliceString(node.from, node.to).trim() !== "mdl") return;
240
+ const tickFrom = node.from - 3;
241
+ if (tickFrom >= 0) builder.add(tickFrom, node.to, Decoration.mark({ class: "cm-mdl-fence-tick" }));
242
+ let child = node.node.parent?.firstChild ?? null;
243
+ while (child && child.name !== "CodeText") child = child.nextSibling ?? null;
244
+ if (!child) return;
245
+ const bodyFrom = child.from;
246
+ const lines = state.doc.sliceString(bodyFrom, child.to).split("\n");
247
+ let lineOffset = 0;
248
+ for (let i = 0; i < lines.length; i++) {
249
+ const line = lines[i];
250
+ const lineFrom = bodyFrom + lineOffset;
251
+ if (i === 0) {
252
+ const headerMatch = line.match(/^(\s*)(\w+)(?:\s+([\w][\w.-]*))?(\s*:\s*)?(.*)?$/);
253
+ if (headerMatch) {
254
+ const [, leadingSpace, blockType, id, colon, label] = headerMatch;
255
+ if (BLOCK_TYPE_COLORS[blockType]) {
256
+ const typeFrom = lineFrom + leadingSpace.length;
257
+ const typeTo = typeFrom + blockType.length;
258
+ builder.add(typeFrom, typeTo, Decoration.mark({ class: `cm-mdl-block-${blockType}` }));
259
+ if (id) {
260
+ const idFrom = typeTo + 1;
261
+ const idTo = idFrom + id.length;
262
+ builder.add(idFrom, idTo, Decoration.mark({ class: "cm-mdl-block-id" }));
263
+ if (colon && label) {
264
+ const labelFrom = idTo + colon.length;
265
+ builder.add(labelFrom, lineFrom + line.length, Decoration.mark({ class: "cm-mdl-block-header" }));
266
+ }
267
+ }
268
+ }
269
+ }
270
+ } else decorateLine(builder, line, lineFrom);
271
+ lineOffset += line.length + 1;
272
+ }
273
+ } });
274
+ return builder.finish();
275
+ };
276
+ /**
277
+ * Decorates Spec mdl fenced blocks:
278
+ * - Mutes the ``` ticks and `mdl` keyword (slate-500)
279
+ * - Colors the block type keyword on the first body line (per-type hue)
280
+ * - Colors field names in block body lines (blue-400)
281
+ * - Colors comments in block body lines (green-400, italic)
282
+ */
283
+ var mdlFenceHighlight = [theme, ViewPlugin.fromClass(class {
284
+ decorations;
285
+ constructor(view) {
286
+ this.decorations = buildDecorations(view);
287
+ }
288
+ update(update) {
289
+ if (update.docChanged || update.viewportChanged) this.decorations = buildDecorations(update.view);
290
+ }
291
+ }, { decorations: (instance) => instance.decorations })];
292
+ //#endregion
293
+ //#region src/extension/lint.ts
294
+ /**
295
+ * Lint extension for Spec .mdl documents; with an index (or a getter for one that loads late) it also
296
+ * checks spec references and dependencies.
297
+ */
298
+ var mdlLint = (index) => linter((view) => lintMdl(view.state.doc.toString(), { index: typeof index === "function" ? index() : index }));
299
+ //#endregion
300
+ //#region src/extension/gen/mdl.terms.ts
301
+ var mdl_terms_exports = /* @__PURE__ */ __exportAll({
302
+ ArrayExpr: () => 15,
303
+ Block: () => 1,
304
+ Comma: () => 12,
305
+ Comment: () => 21,
306
+ FieldName: () => 3,
307
+ KeyValue: () => 2,
308
+ ListExpr: () => 9,
309
+ Number: () => 17,
310
+ NumberRange: () => 16,
311
+ Optional: () => 4,
312
+ Pipe: () => 19,
313
+ TypeAtom: () => 8,
314
+ TypeExpr: () => 7,
315
+ TypeName: () => 11
316
+ });
317
+ //#endregion
318
+ //#region src/extension/gen/mdl.ts
319
+ var parser = LRParser.deserialize({
320
+ version: 14,
321
+ states: "&lQVQPOOOOQO'#C_'#C_OOQO'#Cq'#CqObQPO'#C^OjQPO'#CxOOQO'#Cx'#CxOOQO'#Cr'#CrQVQPOOOOQO'#C`'#C`OoQPO,58xO!QQPO,58xOOQO,59d,59dOOQO-E6p-E6pOOQO'#Cg'#CgO!VQPO'#CeO![QPO'#CdOOQO'#Cm'#CmO!jQPO'#ClOOQO'#Cd'#CdO!oQPO'#CcOOQO1G.d1G.dO!zQPO1G.dO#SQPO1G.dO#eQPO,59PO#mQPO,59VO#rQPO,59WOOQO'#Co'#CoO#wQPO'#CtO$SQPO,58}OOQO7+$O7+$OO$_QPO7+$OOOQO'#Ch'#ChO!VQPO'#CsO$gQPO1G.kOOQO1G.k1G.kOOQO1G.q1G.qOOQO1G.r1G.rOOQO,59`,59`OOQO-E6r-E6rOOQO<<Gj<<GjOOQO,59_,59_OOQO-E6q-E6qOOQO7+$V7+$V",
322
+ stateData: "$r~OkOS~OmPOoQOpTO~OTWOUXO~OpZO~OY^Om]On`OoQOpQa~OUfO~Om]O~OYhOdWXoWXpWX~ObiO~OdjOoVXpVX~OoQOpQi~OY^Om]On`OoQOpQi~O]oO^rO~O^sO~On`O~OY^Om]On`O~OdjOoVapVa~OoQOpQq~O]oO^zO~Oom~",
323
+ goto: "#nmPPnrvPPy!P!WP!]!hPP!W!W!lP!tP!x#W#^#dPPP#jTSOVTROVRYRQeXRnfScXfRukVbXfkU_XfkQg^RxpTpgqUaXfkRtiTkclSSOVQdXSmefRwnQVOR[VQqgRyqQlcRvlTUOV",
324
+ nodeNames: "⚠ Block KeyValue FieldName Optional ? : TypeExpr TypeAtom ListExpr [ TypeName Comma , ] ArrayExpr NumberRange Number .. Pipe | Comment",
325
+ maxTerm: 32,
326
+ skippedNodes: [0],
327
+ repeatNodeCount: 3,
328
+ tokenData: "$k~R`XY!TYZ!`]^!epq!Tst!k|}#S!O!P#X!Q![#d![!]#l!a!b#q!c!}#v!}#O$[#P#Q$a#R#S#v#T#o#v#p#q$f~!YQk~XY!Tpq!T~!eOp~~!hPYZ!`~!pSo~OY!kZ;'S!k;'S;=`!|<%lO!k~#PP;=`<%l!k~#XO]~~#[P!O!P#_~#dOb~~#iPn~!Q![#d~#qOU~~#vOT~~#{Tm~}!O#v!Q![#v!c!}#v#R#S#v#T#o#v~$aOY~~$fO^~~$kOd~",
329
+ tokenizers: [0],
330
+ topRules: { "Block": [0, 1] },
331
+ tokenPrec: 169
332
+ });
333
+ //#endregion
334
+ //#region src/extension/syntax.ts
335
+ /**
336
+ * Language definition for the interior of Spec fenced blocks.
337
+ * Uses the generated Lezer LR parser for structural parsing (completion, linting).
338
+ * Syntax highlighting is handled separately by the regex-based ViewPlugin in fences.ts
339
+ * so that it is immune to LR error-recovery false positives on prose content.
340
+ */
341
+ var mdlBlockLanguage = LRLanguage.define({
342
+ name: "spec-block",
343
+ parser: parser.configure({}),
344
+ languageData: { commentTokens: { line: "#" } }
345
+ });
346
+ /** Node type ids of the generated parser, for callers that walk a parse tree (see `QueryDSL.Node`). */
347
+ var mdlTerms = mdl_terms_exports;
348
+ //#endregion
349
+ //#region src/extension/language.ts
350
+ /**
351
+ * LanguageDescription for MDL fenced block bodies.
352
+ * All Spec blocks use ```mdl fences; the block type is the first body line.
353
+ * Pass this to createMarkdownExtensions({ codeLanguages: [mdlBlockDescription] }).
354
+ */
355
+ var mdlBlockDescription = LanguageDescription.of({
356
+ name: "spec-block",
357
+ alias: ["mdl"],
358
+ support: new LanguageSupport(mdlBlockLanguage)
359
+ });
360
+ /**
361
+ * CodeMirror extensions for Spec .mdl block-body highlighting and fence decoration, and for the
362
+ * highlighting of fenced code in other languages.
363
+ * Given an `index`, it also lints spec references and dependencies against it.
364
+ * Does NOT include the Markdown language itself — pass mdlBlockDescription to
365
+ * createMarkdownExtensions() instead so it merges cleanly with the standard language set.
366
+ */
367
+ var mdl = ({ index } = {}) => index ? [
368
+ mdlFenceHighlight,
369
+ codeFenceHighlight,
370
+ mdlLint(index)
371
+ ] : [mdlFenceHighlight, codeFenceHighlight];
372
+ //#endregion
373
+ //#region src/extension/complete.ts
374
+ /** Field-name completions inside a Spec fenced block, from {@link fieldCompletionContext}. */
375
+ var mdlCompletionSource = (context) => {
376
+ const found = fieldCompletionContext(context.state.doc.toString(), context.pos);
377
+ if (!found) return null;
378
+ const word = context.matchBefore(/\w[\w-]*/);
379
+ if (!word && !context.explicit) return null;
380
+ return {
381
+ from: word ? word.from : context.pos,
382
+ options: found.fields.map((field) => ({
383
+ label: field,
384
+ type: "property",
385
+ apply: `${field}: `
386
+ }))
387
+ };
388
+ };
389
+ /**
390
+ * Autocompletion extension for Spec .mdl documents.
391
+ */
392
+ var mdlComplete = autocompletion({ override: [mdlCompletionSource] });
393
+ //#endregion
394
+ export { mdlLint as a, mdlTerms as i, mdl as n, mdlBlockDescription as r, mdlComplete as t };
395
+
396
+ //# sourceMappingURL=chunk-extension.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-extension.mjs","names":["theme","buildDecorations","terms"],"sources":["../../src/extension/code.ts","../../src/extension/fences.ts","../../src/extension/lint.ts","../../src/extension/gen/mdl.terms.ts","../../src/extension/gen/mdl.ts","../../src/extension/syntax.ts","../../src/extension/language.ts","../../src/extension/complete.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type EditorState, type Extension, RangeSetBuilder } from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate } from '@codemirror/view';\nimport { highlightTree, tagHighlighter, tags } from '@lezer/highlight';\n\n/** Fences that other extensions colour, or that have no nested language. */\nconst SKIPPED_FENCES = new Set(['', 'mdl', 'diagram', 'mermaid']);\n\nconst highlighter = tagHighlighter([\n {\n tag: [\n tags.keyword,\n tags.controlKeyword,\n tags.definitionKeyword,\n tags.moduleKeyword,\n tags.operatorKeyword,\n tags.modifier,\n ],\n class: 'cm-code-keyword',\n },\n { tag: [tags.string, tags.special(tags.string), tags.regexp, tags.escape], class: 'cm-code-string' },\n { tag: [tags.number, tags.bool, tags.null, tags.atom], class: 'cm-code-literal' },\n { tag: [tags.comment, tags.lineComment, tags.blockComment, tags.docComment], class: 'cm-code-comment' },\n { tag: [tags.typeName, tags.className, tags.namespace], class: 'cm-code-type' },\n { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], class: 'cm-code-function' },\n { tag: [tags.propertyName, tags.definition(tags.propertyName)], class: 'cm-code-property' },\n]);\n\n// The markdown highlight style sets code tokens to `color: inherit !important`, so a mark's colour shows through.\nconst theme = EditorView.baseTheme({\n '.cm-code-keyword': { color: 'var(--color-violet-400)' },\n '.cm-code-string': { color: 'var(--color-emerald-400)' },\n '.cm-code-literal': { color: 'var(--color-orange-400)' },\n '.cm-code-comment': { color: 'var(--color-slate-400)', fontStyle: 'italic' },\n '.cm-code-type': { color: 'var(--color-sky-400)' },\n '.cm-code-function': { color: 'var(--color-amber-400)' },\n '.cm-code-property': { color: 'var(--color-blue-400)' },\n});\n\nconst fenceLanguage = (state: EditorState, from: number, to: number): string =>\n state.sliceDoc(from, to).trim().split(/\\s/)[0].toLowerCase();\n\nconst buildDecorations = (view: EditorView): DecorationSet => {\n const builder = new RangeSetBuilder<Decoration>();\n const tree = syntaxTree(view.state);\n for (const { from, to } of view.visibleRanges) {\n tree.iterate({\n from,\n to,\n enter: (node) => {\n if (node.name !== 'FencedCode') {\n return;\n }\n const info = node.node.getChild('CodeInfo');\n const text = node.node.getChild('CodeText');\n if (text && !SKIPPED_FENCES.has(info ? fenceLanguage(view.state, info.from, info.to) : '')) {\n highlightTree(\n tree,\n highlighter,\n (start, end, cls) => builder.add(start, end, Decoration.mark({ class: cls })),\n Math.max(text.from, from),\n Math.min(text.to, to),\n );\n }\n return false;\n },\n });\n }\n return builder.finish();\n};\n\n/**\n * Colours the fenced code of other languages (`ts`, `sql`, …) in a spec, whose tokens the markdown\n * highlight style leaves uncoloured.\n */\nexport const codeFenceHighlight: Extension = [\n theme,\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // A fence language loads after the first parse, which changes the tree without changing the doc.\n if (update.docChanged || update.viewportChanged || syntaxTree(update.startState) !== syntaxTree(update.state)) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n { decorations: (plugin) => plugin.decorations },\n ),\n];\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type Extension, RangeSetBuilder } from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate } from '@codemirror/view';\n\nimport { BLOCK_TYPES } from './constants.ts';\n\n// Per-type hue palette for block type keyword.\nconst BLOCK_TYPE_COLORS: Record<(typeof BLOCK_TYPES)[number], string> = {\n ext: 'var(--color-violet-400)',\n type: 'var(--color-blue-400)',\n op: 'var(--color-orange-400)',\n feat: 'var(--color-emerald-400)',\n feature: 'var(--color-sky-400)',\n scenario: 'var(--color-cyan-400)',\n test: 'var(--color-teal-400)',\n component: 'var(--color-pink-400)',\n service: 'var(--color-yellow-400)',\n db: 'var(--color-red-400)',\n module: 'var(--color-indigo-400)',\n suite: 'var(--color-lime-400)',\n decision: 'var(--color-amber-400)',\n question: 'var(--color-orange-300)',\n verdict: 'var(--color-green-400)',\n plugin: 'var(--color-fuchsia-400)',\n uses: 'var(--color-rose-400)',\n table: 'var(--color-red-400)',\n};\n\nconst theme = EditorView.baseTheme({\n '.cm-mdl-fence-tick': { color: 'var(--color-slate-400)' },\n '.cm-mdl-block-id': { color: 'var(--color-orange-400)' },\n '.cm-mdl-block-header': { color: 'var(--color-pink-400)' },\n '.cm-mdl-field': { color: 'var(--color-blue-400)' },\n '.cm-mdl-punct': { color: 'var(--color-slate-400)' },\n '.cm-mdl-comment': { color: 'var(--color-green-400)', fontStyle: 'italic' },\n ...Object.fromEntries(\n Object.entries(BLOCK_TYPE_COLORS).map(([type, color]) => [`& .cm-mdl-block-${type}`, { color }]),\n ),\n});\n\n/** Color a single line of the block body using regex matching. */\nconst decorateLine = (builder: RangeSetBuilder<Decoration>, lineText: string, lineFrom: number): void => {\n const trimmed = lineText.trimStart();\n const indent = lineText.length - trimmed.length;\n const abs = (offset: number) => lineFrom + offset;\n\n // Standalone comment line.\n if (trimmed.startsWith('#')) {\n builder.add(abs(indent), abs(lineText.length), Decoration.mark({ class: 'cm-mdl-comment' }));\n return;\n }\n\n // Field name line: \"<fieldName> [id][?]: value\"\n // e.g. \"req F-1.1: prose\", \"kind: PieceKind\", \"piece?: Piece\"\n const lineMatch = trimmed.match(/^([\\w][\\w-]*)(?:\\s+([\\w][\\w.-]*))?(\\??)(\\s*:)(.*)/s);\n if (!lineMatch) {\n // No field pattern — still color any trailing \" #\" comment.\n const commentIdx = lineText.indexOf(' #', indent);\n if (commentIdx >= 0) {\n builder.add(abs(commentIdx + 1), abs(lineText.length), Decoration.mark({ class: 'cm-mdl-comment' }));\n }\n return;\n }\n\n const [, fieldName, id, optMarker, colonPart] = lineMatch;\n\n // Field name.\n const fieldFrom = abs(indent);\n const fieldTo = fieldFrom + fieldName.length;\n builder.add(fieldFrom, fieldTo, Decoration.mark({ class: 'cm-mdl-field' }));\n\n let pos = indent + fieldName.length;\n\n // Optional id between field name and colon (e.g. F-1.1).\n if (id) {\n const idFrom = abs(pos + 1); // +1 for the space\n const idTo = idFrom + id.length;\n builder.add(idFrom, idTo, Decoration.mark({ class: 'cm-mdl-block-id' }));\n pos += 1 + id.length;\n }\n\n // Optional ? marker.\n if (optMarker) {\n builder.add(abs(pos), abs(pos + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n pos += 1;\n }\n\n // Colon — last char of colonPart (colonPart matches \\s*:).\n const colonPos = pos + colonPart.length - 1;\n builder.add(abs(colonPos), abs(colonPos + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n pos += colonPart.length;\n\n // Inline comment: first \" #\" after the colon.\n const commentOffset = lineText.indexOf(' #', pos);\n const valueEnd = commentOffset >= 0 ? commentOffset : lineText.length;\n\n // Value expression highlighting (must come before comment to maintain ascending order).\n const valueStart = pos;\n const valuePart = lineText.slice(valueStart, valueEnd);\n\n // Bracketed identifier list (e.g. \"[InvalidMove, WrongTurn, GameOver]\").\n // RangeSetBuilder requires decorations in ascending order, so we scan left-to-right.\n const bracketMatch = valuePart.match(/^\\s*\\[([^\\]]*)\\]/);\n if (bracketMatch) {\n const openIdx = valueStart + valuePart.indexOf('[');\n const closeIdx = valueStart + valuePart.indexOf(']');\n builder.add(abs(openIdx), abs(openIdx + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n\n // Scan inner content left-to-right for identifiers and commas.\n const inner = bracketMatch[1];\n const tokenRe = /(\\w[\\w-]*)|,/g;\n let token: RegExpExecArray | null;\n while ((token = tokenRe.exec(inner)) !== null) {\n const tokenFrom = openIdx + 1 + token.index;\n if (token[1]) {\n builder.add(abs(tokenFrom), abs(tokenFrom + token[0].length), Decoration.mark({ class: 'cm-mdl-block-id' }));\n } else {\n builder.add(abs(tokenFrom), abs(tokenFrom + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n }\n }\n\n builder.add(abs(closeIdx), abs(closeIdx + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n }\n\n // Pipe separators in union types (e.g. \"a | b | c\").\n let pipeIdx = valuePart.indexOf('|');\n while (pipeIdx >= 0) {\n const absIdx = valueStart + pipeIdx;\n builder.add(abs(absIdx), abs(absIdx + 1), Decoration.mark({ class: 'cm-mdl-punct' }));\n pipeIdx = valuePart.indexOf('|', pipeIdx + 1);\n }\n\n // Inline comment added last to keep RangeSetBuilder insertion monotonic.\n if (commentOffset >= 0) {\n builder.add(abs(commentOffset + 1), abs(lineText.length), Decoration.mark({ class: 'cm-mdl-comment' }));\n }\n};\n\nconst buildDecorations = (view: EditorView): DecorationSet => {\n const builder = new RangeSetBuilder<Decoration>();\n const { state } = view;\n\n // Frontmatter: detect YAML block at document start, delimited by ---.\n const docText = state.doc.toString();\n const fmMatch = docText.match(/^---\\n([\\s\\S]*?\\n)---(?:\\n|$)/);\n if (fmMatch) {\n // Opening ---.\n builder.add(0, 3, Decoration.mark({ class: 'cm-mdl-fence-tick' }));\n\n // Key-value lines inside frontmatter.\n const fmContent = fmMatch[1];\n let lineOffset = 4; // skip '---\\n'\n for (const line of fmContent.split('\\n')) {\n if (line.trim()) {\n decorateLine(builder, line, lineOffset);\n }\n lineOffset += line.length + 1;\n }\n\n // Closing ---.\n const closeFrom = 4 + fmMatch[1].length;\n builder.add(closeFrom, closeFrom + 3, Decoration.mark({ class: 'cm-mdl-fence-tick' }));\n }\n\n syntaxTree(state).iterate({\n enter(node) {\n if (node.name !== 'CodeInfo') {\n return;\n }\n\n // Only handle ```mdl fences.\n if (state.doc.sliceString(node.from, node.to).trim() !== 'mdl') {\n return;\n }\n\n // Color ``` ticks + \"mdl\" keyword in muted grey.\n const tickFrom = node.from - 3;\n if (tickFrom >= 0) {\n builder.add(tickFrom, node.to, Decoration.mark({ class: 'cm-mdl-fence-tick' }));\n }\n\n // Find the CodeText sibling that holds the block body.\n let child = node.node.parent?.firstChild ?? null;\n while (child && child.name !== 'CodeText') {\n child = child.nextSibling ?? null;\n }\n if (!child) {\n return;\n }\n\n const bodyFrom = child.from;\n const bodyText = state.doc.sliceString(bodyFrom, child.to);\n const lines = bodyText.split('\\n');\n let lineOffset = 0;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n const lineFrom = bodyFrom + lineOffset;\n\n if (i === 0) {\n // First body line: \"<blockType> [id][: label]\"\n // e.g. \"type Color\", \"feat F-1: Start Game\", \"test T-1: description\"\n const headerMatch = line.match(/^(\\s*)(\\w+)(?:\\s+([\\w][\\w.-]*))?(\\s*:\\s*)?(.*)?$/);\n if (headerMatch) {\n const [, leadingSpace, blockType, id, colon, label] = headerMatch;\n const color = BLOCK_TYPE_COLORS[blockType as (typeof BLOCK_TYPES)[number]];\n if (color) {\n // Block type keyword.\n const typeFrom = lineFrom + leadingSpace.length;\n const typeTo = typeFrom + blockType.length;\n builder.add(typeFrom, typeTo, Decoration.mark({ class: `cm-mdl-block-${blockType}` }));\n\n // Identifier (e.g. F-1, T-1, Color) — white/bright so it stands out.\n if (id) {\n const idFrom = typeTo + 1; // +1 for the space\n const idTo = idFrom + id.length;\n builder.add(idFrom, idTo, Decoration.mark({ class: 'cm-mdl-block-id' }));\n\n // Label after colon — muted.\n if (colon && label) {\n const labelFrom = idTo + colon.length;\n builder.add(labelFrom, lineFrom + line.length, Decoration.mark({ class: 'cm-mdl-block-header' }));\n }\n }\n }\n }\n } else {\n decorateLine(builder, line, lineFrom);\n }\n\n lineOffset += line.length + 1; // +1 for '\\n'\n }\n },\n });\n\n return builder.finish();\n};\n\n/**\n * Decorates Spec mdl fenced blocks:\n * - Mutes the ``` ticks and `mdl` keyword (slate-500)\n * - Colors the block type keyword on the first body line (per-type hue)\n * - Colors field names in block body lines (blue-400)\n * - Colors comments in block body lines (green-400, italic)\n */\nexport const mdlFenceHighlight: Extension = [\n theme,\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n if (update.docChanged || update.viewportChanged) {\n this.decorations = buildDecorations(update.view);\n }\n }\n },\n {\n decorations: (instance) => instance.decorations,\n },\n ),\n];\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Diagnostic, linter } from '@codemirror/lint';\nimport { type Extension } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\n\nimport { type SpecIndex } from '../spec-index/spec-index.ts';\nimport { lintMdl } from './check.ts';\n\n/**\n * Lint extension for Spec .mdl documents; with an index (or a getter for one that loads late) it also\n * checks spec references and dependencies.\n */\nexport const mdlLint = (index?: SpecIndex | (() => SpecIndex | undefined)): Extension =>\n linter((view: EditorView): Diagnostic[] =>\n lintMdl(view.state.doc.toString(), { index: typeof index === 'function' ? index() : index }),\n );\n","// This file was generated by lezer-generator. You probably shouldn't edit it.\nexport const\n Block = 1,\n KeyValue = 2,\n FieldName = 3,\n Optional = 4,\n TypeExpr = 7,\n TypeAtom = 8,\n ListExpr = 9,\n TypeName = 11,\n Comma = 12,\n ArrayExpr = 15,\n NumberRange = 16,\n Number = 17,\n Pipe = 19,\n Comment = 21\n","// This file was generated by lezer-generator. You probably shouldn't edit it.\nimport {LRParser} from \"@lezer/lr\"\nexport const parser = LRParser.deserialize({\n version: 14,\n states: \"&lQVQPOOOOQO'#C_'#C_OOQO'#Cq'#CqObQPO'#C^OjQPO'#CxOOQO'#Cx'#CxOOQO'#Cr'#CrQVQPOOOOQO'#C`'#C`OoQPO,58xO!QQPO,58xOOQO,59d,59dOOQO-E6p-E6pOOQO'#Cg'#CgO!VQPO'#CeO![QPO'#CdOOQO'#Cm'#CmO!jQPO'#ClOOQO'#Cd'#CdO!oQPO'#CcOOQO1G.d1G.dO!zQPO1G.dO#SQPO1G.dO#eQPO,59PO#mQPO,59VO#rQPO,59WOOQO'#Co'#CoO#wQPO'#CtO$SQPO,58}OOQO7+$O7+$OO$_QPO7+$OOOQO'#Ch'#ChO!VQPO'#CsO$gQPO1G.kOOQO1G.k1G.kOOQO1G.q1G.qOOQO1G.r1G.rOOQO,59`,59`OOQO-E6r-E6rOOQO<<Gj<<GjOOQO,59_,59_OOQO-E6q-E6qOOQO7+$V7+$V\",\n stateData: \"$r~OkOS~OmPOoQOpTO~OTWOUXO~OpZO~OY^Om]On`OoQOpQa~OUfO~Om]O~OYhOdWXoWXpWX~ObiO~OdjOoVXpVX~OoQOpQi~OY^Om]On`OoQOpQi~O]oO^rO~O^sO~On`O~OY^Om]On`O~OdjOoVapVa~OoQOpQq~O]oO^zO~Oom~\",\n goto: \"#nmPPnrvPPy!P!WP!]!hPP!W!W!lP!tP!x#W#^#dPPP#jTSOVTROVRYRQeXRnfScXfRukVbXfkU_XfkQg^RxpTpgqUaXfkRtiTkclSSOVQdXSmefRwnQVOR[VQqgRyqQlcRvlTUOV\",\n nodeNames: \"⚠ Block KeyValue FieldName Optional ? : TypeExpr TypeAtom ListExpr [ TypeName Comma , ] ArrayExpr NumberRange Number .. Pipe | Comment\",\n maxTerm: 32,\n skippedNodes: [0],\n repeatNodeCount: 3,\n tokenData: \"$k~R`XY!TYZ!`]^!epq!Tst!k|}#S!O!P#X!Q![#d![!]#l!a!b#q!c!}#v!}#O$[#P#Q$a#R#S#v#T#o#v#p#q$f~!YQk~XY!Tpq!T~!eOp~~!hPYZ!`~!pSo~OY!kZ;'S!k;'S;=`!|<%lO!k~#PP;=`<%l!k~#XO]~~#[P!O!P#_~#dOb~~#iPn~!Q![#d~#qOU~~#vOT~~#{Tm~}!O#v!Q![#v!c!}#v#R#S#v#T#o#v~$aOY~~$fO^~~$kOd~\",\n tokenizers: [0],\n topRules: {\"Block\":[0,1]},\n tokenPrec: 169\n})\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { LRLanguage } from '@codemirror/language';\n\nimport * as terms from './gen/mdl.terms.ts';\nimport { parser } from './gen/mdl.ts';\n\n/**\n * Language definition for the interior of Spec fenced blocks.\n * Uses the generated Lezer LR parser for structural parsing (completion, linting).\n * Syntax highlighting is handled separately by the regex-based ViewPlugin in fences.ts\n * so that it is immune to LR error-recovery false positives on prose content.\n */\nexport const mdlBlockLanguage = LRLanguage.define({\n name: 'spec-block',\n parser: parser.configure({}),\n languageData: {\n commentTokens: { line: '#' },\n },\n});\n\n/** Node type ids of the generated parser, for callers that walk a parse tree (see `QueryDSL.Node`). */\nexport const mdlTerms = terms;\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { LanguageDescription, LanguageSupport } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\n\nimport { type SpecIndex } from '../spec-index/spec-index.ts';\nimport { codeFenceHighlight } from './code.ts';\nimport { mdlFenceHighlight } from './fences.ts';\nimport { mdlLint } from './lint.ts';\nimport { mdlBlockLanguage } from './syntax.ts';\n\n/**\n * LanguageDescription for MDL fenced block bodies.\n * All Spec blocks use ```mdl fences; the block type is the first body line.\n * Pass this to createMarkdownExtensions({ codeLanguages: [mdlBlockDescription] }).\n */\nexport const mdlBlockDescription = LanguageDescription.of({\n name: 'spec-block',\n alias: ['mdl'],\n support: new LanguageSupport(mdlBlockLanguage),\n});\n\n/**\n * CodeMirror extensions for Spec .mdl block-body highlighting and fence decoration, and for the\n * highlighting of fenced code in other languages.\n * Given an `index`, it also lints spec references and dependencies against it.\n * Does NOT include the Markdown language itself — pass mdlBlockDescription to\n * createMarkdownExtensions() instead so it merges cleanly with the standard language set.\n */\nexport const mdl = ({ index }: { index?: SpecIndex | (() => SpecIndex | undefined) } = {}): Extension =>\n index ? [mdlFenceHighlight, codeFenceHighlight, mdlLint(index)] : [mdlFenceHighlight, codeFenceHighlight];\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type CompletionContext, type CompletionResult, autocompletion } from '@codemirror/autocomplete';\nimport { type Extension } from '@codemirror/state';\n\nimport { fieldCompletionContext } from './completion.ts';\n\n/** Field-name completions inside a Spec fenced block, from {@link fieldCompletionContext}. */\nconst mdlCompletionSource = (context: CompletionContext): CompletionResult | null => {\n const found = fieldCompletionContext(context.state.doc.toString(), context.pos);\n if (!found) {\n return null;\n }\n const word = context.matchBefore(/\\w[\\w-]*/);\n if (!word && !context.explicit) {\n return null;\n }\n\n return {\n from: word ? word.from : context.pos,\n options: found.fields.map((field) => ({\n label: field,\n type: 'property',\n apply: `${field}: `,\n })),\n };\n};\n\n/**\n * Autocompletion extension for Spec .mdl documents.\n */\nexport const mdlComplete: Extension = autocompletion({ override: [mdlCompletionSource] });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUA,IAAM,iCAAiB,IAAI,IAAI;CAAC;CAAI;CAAO;CAAW;AAAS,CAAC;AAEhE,IAAM,cAAc,eAAe;CACjC;EACE,KAAK;GACH,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;GACL,KAAK;EACP;EACA,OAAO;CACT;CACA;EAAE,KAAK;GAAC,KAAK;GAAQ,KAAK,QAAQ,KAAK,MAAM;GAAG,KAAK;GAAQ,KAAK;EAAM;EAAG,OAAO;CAAiB;CACnG;EAAE,KAAK;GAAC,KAAK;GAAQ,KAAK;GAAM,KAAK;GAAM,KAAK;EAAI;EAAG,OAAO;CAAkB;CAChF;EAAE,KAAK;GAAC,KAAK;GAAS,KAAK;GAAa,KAAK;GAAc,KAAK;EAAU;EAAG,OAAO;CAAkB;CACtG;EAAE,K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AU,EAAC,SAAQ,CAAC,GAAE,CAAC,EAAC;CACxB,WAAW;AACb,CAAC;;;;;;;;;ACAD,IAAa,mBAAmB,WAAW,OAAO;CAChD,MAAM;CACN,QAAQ,OAAO,UAAU,CAAC,CAAC;CAC3B,cAAc,EACZ,eAAe,EAAE,MAAM,IAAI,EAC7B;AACF,CAAC;;AAGD,IAAa,WAAWC;;;;;;;;ACNxB,IAAa,sBAAsB,oBAAoB,GAAG;CACxD,MAAM;CACN,OAAO,CAAC,KAAK;CACb,SAAS,IAAI,gBAAgB,gBAAgB;AAC/C,CAAC;;;;;;;;AASD,IAAa,OAAO,EAAE,UAAiE,CAAC,MACtF,QAAQ;CAAC;CAAmB;CAAoB,QAAQ,KAAK;AAAC,IAAI,CAAC,mBAAmB,kBAAkB;;;;ACtB1G,IAAM,uBAAuB,YAAwD;CACnF,MAAM,QAAQ,uBAAuB,QAAQ,MAAM,IAAI,SAAS,GAAG,QAAQ,GAAG;CAC9E,IAAI,CAAC,OACH,OAAO;CAET,MAAM,OAAO,QAAQ,YAAY,UAAU;CAC3C,IAAI,CAAC,QAAQ,CAAC,QAAQ,UACpB,OAAO;CAGT,OAAO;EACL,MAAM,OAAO,KAAK,OAAO,QAAQ;EACjC,SAAS,MAAM,OAAO,KAAK,WAAW;GACpC,OAAO;GACP,MAAM;GACN,OAAO,GAAG,MAAM;EAClB,EAAE;CACJ;AACF;;;;AAKA,IAAa,cAAyB,eAAe,EAAE,UAAU,CAAC,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ //#region src/spec-index/parse.ts
2
+ /** The flat `key: value` pairs of a document's YAML frontmatter. */
3
+ var frontmatter = (text) => Object.fromEntries((text.match(/^---\n([\s\S]*?)\n---/)?.[1] ?? "").split("\n").flatMap((line) => {
4
+ const match = line.match(/^([\w-]+):\s*(.*?)\s*(?:#.*)?$/);
5
+ return match ? [[match[1], match[2]]] : [];
6
+ }));
7
+ /** The `req` lines nested in a block body, with each one's line offset within the body. */
8
+ var reqs = (body) => body.split("\n").flatMap((text, offset) => {
9
+ const req = text.match(/^\s+req\s+([A-Za-z][\w.-]*)\s*:\s*(.*)$/);
10
+ return req ? [{
11
+ id: req[1],
12
+ title: req[2],
13
+ offset
14
+ }] : [];
15
+ });
16
+ /** The ids of the `req` lines nested in a block body. */
17
+ var reqIds = (body) => reqs(body).map(({ id }) => id);
18
+ //#endregion
19
+ export { reqIds as n, reqs as r, frontmatter as t };
20
+
21
+ //# sourceMappingURL=chunk-parse.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-parse.mjs","names":[],"sources":["../../src/spec-index/parse.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n/** The flat `key: value` pairs of a document's YAML frontmatter. */\nexport const frontmatter = (text: string): Record<string, string> =>\n Object.fromEntries(\n (text.match(/^---\\n([\\s\\S]*?)\\n---/)?.[1] ?? '').split('\\n').flatMap((line) => {\n const match = line.match(/^([\\w-]+):\\s*(.*?)\\s*(?:#.*)?$/);\n return match ? [[match[1], match[2]]] : [];\n }),\n );\n\n/** The `req` lines nested in a block body, with each one's line offset within the body. */\nexport const reqs = (body: string): { id: string; title: string; offset: number }[] =>\n body.split('\\n').flatMap((text, offset) => {\n const req = text.match(/^\\s+req\\s+([A-Za-z][\\w.-]*)\\s*:\\s*(.*)$/);\n return req ? [{ id: req[1], title: req[2], offset }] : [];\n });\n\n/** The ids of the `req` lines nested in a block body. */\nexport const reqIds = (body: string): string[] => reqs(body).map(({ id }) => id);\n"],"mappings":";;AAKA,IAAa,eAAe,SAC1B,OAAO,aACJ,KAAK,MAAM,uBAAuB,CAAC,GAAG,MAAM,GAAA,CAAI,MAAM,IAAI,CAAC,CAAC,SAAS,SAAS;CAC7E,MAAM,QAAQ,KAAK,MAAM,gCAAgC;CACzD,OAAO,QAAQ,CAAC,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC,IAAI,CAAC;AAC3C,CAAC,CACH;;AAGF,IAAa,QAAQ,SACnB,KAAK,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,WAAW;CACzC,MAAM,MAAM,KAAK,MAAM,yCAAyC;CAChE,OAAO,MAAM,CAAC;EAAE,IAAI,IAAI;EAAI,OAAO,IAAI;EAAI;CAAO,CAAC,IAAI,CAAC;AAC1D,CAAC;;AAGH,IAAa,UAAU,SAA2B,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE"}