@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,452 @@
1
+ import { n as reqIds, t as frontmatter } from "./chunk-parse.mjs";
2
+ import { a as parseBlockHeaders, i as findInnerBlockHeaders, o as parseMdlBlocks, r as extensionTerms, s as scanFenceLines } from "./chunk-blocks.mjs";
3
+ //#region src/extension/constants.ts
4
+ /**
5
+ * Known Spec block types from the core + standard dialect.
6
+ * In future this will be derived from the Extensions table in the document.
7
+ */
8
+ var BLOCK_TYPES = [
9
+ "ext",
10
+ "type",
11
+ "op",
12
+ "feat",
13
+ "feature",
14
+ "scenario",
15
+ "test",
16
+ "component",
17
+ "service",
18
+ "db",
19
+ "module",
20
+ "suite",
21
+ "decision",
22
+ "question",
23
+ "verdict",
24
+ "plugin",
25
+ "uses",
26
+ "table"
27
+ ];
28
+ //#endregion
29
+ //#region src/extension/refs.ts
30
+ var REF = /(?<![\w/:.#-])([a-z][a-z0-9-]*(?:\.[a-zA-Z0-9-]+)+)#([\w$.-]*\w)/g;
31
+ /**
32
+ * Calls `visit` for each line of prose and of `mdl` fences, with the line's offset in the text.
33
+ * Every other fenced block is skipped, since it holds code rather than spec text.
34
+ */
35
+ var scanSpecLines = (text, visit) => scanFenceLines(text, ({ line, offset, kind, mdl }) => {
36
+ if (kind === "prose" || kind === "body" && mdl) visit(line, offset);
37
+ });
38
+ /** Finds `<spec id>#<item>` references in prose and in `mdl` fences (comments included). */
39
+ var findSpecRefs = (text) => {
40
+ const refs = [];
41
+ scanSpecLines(text, (line, offset) => {
42
+ for (const match of line.matchAll(REF)) {
43
+ const from = offset + match.index;
44
+ refs.push({
45
+ id: match[1],
46
+ item: match[2],
47
+ from,
48
+ to: from + match[0].length
49
+ });
50
+ }
51
+ });
52
+ return refs;
53
+ };
54
+ var GITHUB_SPEC_KEY = /github:[^\s`'")\]>,]*?\.mdl(?![\w/-]|\.\w)(?:#[\w$.-]*)?/g;
55
+ /** Finds `github:` keys that point at a `.mdl` file, with the offsets of the whole key. */
56
+ var findSpecKeys = (text) => {
57
+ const keys = [];
58
+ scanSpecLines(text, (line, offset) => {
59
+ for (const match of line.matchAll(GITHUB_SPEC_KEY)) keys.push({
60
+ from: offset + match.index,
61
+ to: offset + match.index + match[0].length
62
+ });
63
+ });
64
+ return keys;
65
+ };
66
+ /**
67
+ * The specs this one depends on: every `uses` block id and every entry of the `plugin` block's
68
+ * `dependsOn: [...]`, in document order.
69
+ */
70
+ var specDependencies = (text) => {
71
+ const deps = [];
72
+ for (const { type, id, from, body } of parseMdlBlocks(text)) {
73
+ const headerStart = text.indexOf("\n", from) + 1;
74
+ const bodyStart = text.indexOf("\n", headerStart) + 1;
75
+ if (type === "uses" && id) {
76
+ const idFrom = text.indexOf(id, headerStart + text.slice(headerStart).search(/\S/) + type.length);
77
+ deps.push({
78
+ id,
79
+ via: "uses",
80
+ from: idFrom,
81
+ to: idFrom + id.length
82
+ });
83
+ } else if (type === "plugin") {
84
+ let lineFrom = bodyStart;
85
+ let inList = false;
86
+ for (const line of body.split("\n")) {
87
+ const field = line.match(/^[ \t]+dependsOn:[ \t]*(.*?)[ \t]*$/);
88
+ if (field) {
89
+ const inline = field[1].match(/^\[([^\]]*)\]/);
90
+ inList = field[1] === "" || field[1].startsWith("#");
91
+ if (inline) {
92
+ const listFrom = lineFrom + line.indexOf("[", line.indexOf("dependsOn:")) + 1;
93
+ for (const entry of inline[1].matchAll(/[^\s,]+/g)) {
94
+ const idFrom = listFrom + entry.index;
95
+ deps.push({
96
+ id: entry[0],
97
+ via: "dependsOn",
98
+ from: idFrom,
99
+ to: idFrom + entry[0].length
100
+ });
101
+ }
102
+ }
103
+ } else if (inList) {
104
+ const item = line.match(/^[ \t]+-[ \t]+([^\s#]+)/);
105
+ if (item) {
106
+ const idFrom = lineFrom + line.indexOf(item[1]);
107
+ deps.push({
108
+ id: item[1],
109
+ via: "dependsOn",
110
+ from: idFrom,
111
+ to: idFrom + item[1].length
112
+ });
113
+ } else if (line.trim() !== "") inList = false;
114
+ }
115
+ lineFrom += line.length + 1;
116
+ }
117
+ }
118
+ }
119
+ return deps;
120
+ };
121
+ //#endregion
122
+ //#region src/extension/check.ts
123
+ var KNOWN_BLOCK_TYPES = new Set(BLOCK_TYPES);
124
+ var USER_REF = /^user:\S+$/;
125
+ var AGENT_REF = /^agent:\S+$/;
126
+ var fieldValue = (body, field) => body.match(new RegExp(`^\\s+${field}:[ \\t]*(.*?)[ \\t]*(?:#.*)?$`, "m"))?.[1];
127
+ /**
128
+ * Checks the attribution rules of the changelog dialect (`lang/changelog.mdl`), which keep
129
+ * decisions made by people and decisions made by agents separable. A `question` is attributed the same way.
130
+ */
131
+ var lintAttribution = (body, noun) => {
132
+ const errors = [];
133
+ const by = fieldValue(body, "by");
134
+ const principal = fieldValue(body, "for");
135
+ if (!by) errors.push(`${noun} is missing \`by:\` — name the user: or agent: that made it.`);
136
+ else if (AGENT_REF.test(by)) {
137
+ if (!principal) errors.push(`Agent ${noun.toLowerCase()} is missing \`for:\` — name the user: the agent acted for.`);
138
+ } else if (USER_REF.test(by)) {
139
+ if (principal !== void 0) errors.push(`\`for:\` applies only to agent ${noun.toLowerCase()}s.`);
140
+ } else errors.push(`${noun} \`by: ${by}\` must be \`user:<handle>\` or \`agent:<name>\`.`);
141
+ if (principal && !USER_REF.test(principal)) errors.push(`\`for: ${principal}\` must be \`user:<handle>\`.`);
142
+ return errors;
143
+ };
144
+ var namespace = (id) => id.split(".").slice(0, 2).join(".");
145
+ /** Lint message for an id the index does not hold. */
146
+ var unknownSpecMessage = (id) => `Unknown spec \`${id}\`.`;
147
+ /** Lint message for a reference to an item the spec does not declare. */
148
+ var missingItemMessage = (id, item) => `\`${id}\` has no item \`${item}\`.`;
149
+ /** Lint message for an id more than one file claims. */
150
+ var duplicateSpecMessage = (id) => `Spec id \`${id}\` is declared by more than one file.`;
151
+ /**
152
+ * Whether a `<id>#<item>` candidate is a spec reference rather than prose (a file name, an external schema id):
153
+ * its id is indexed, or shares its first two dotted segments with an indexed id.
154
+ */
155
+ var specReferenceFilter = (index) => {
156
+ const namespaces = new Set([...Object.keys(index.specs), ...Object.keys(index.duplicates)].map(namespace));
157
+ return (id) => namespaces.has(namespace(id));
158
+ };
159
+ var lintReferences = (text, index, selfId) => {
160
+ const diagnostics = [];
161
+ const report = (source, from, to, message) => diagnostics.push({
162
+ from,
163
+ to,
164
+ severity: "error",
165
+ source,
166
+ message
167
+ });
168
+ const dependencies = specDependencies(text);
169
+ const dependsOn = new Set(dependencies.filter(({ via }) => via === "dependsOn").map(({ id }) => id));
170
+ const declared = /* @__PURE__ */ new Set();
171
+ if (selfId && selfId in index.duplicates) {
172
+ const idLine = /^id:.*$/m.exec(text);
173
+ report("mdl/uses", idLine?.index ?? 0, (idLine?.index ?? 0) + (idLine?.[0].length ?? 0), duplicateSpecMessage(selfId));
174
+ }
175
+ for (const { id, via, from, to } of dependencies) {
176
+ if (id === selfId) report("mdl/uses", from, to, "A spec cannot use itself.");
177
+ else if (id in index.duplicates) report("mdl/uses", from, to, duplicateSpecMessage(id));
178
+ else if (!(id in index.specs)) report("mdl/uses", from, to, unknownSpecMessage(id));
179
+ else if (via === "uses" && dependsOn.has(id)) report("mdl/uses", from, to, `\`${id}\` is in dependsOn; do not repeat it under uses.`);
180
+ else if (declared.has(id)) report("mdl/uses", from, to, `\`${id}\` is declared twice.`);
181
+ declared.add(id);
182
+ }
183
+ const isReference = specReferenceFilter(index);
184
+ const dependencyIds = new Set(dependencies.map(({ id }) => id));
185
+ let ownItems;
186
+ for (const { id, item, from, to } of findSpecRefs(text)) {
187
+ if (id === selfId) {
188
+ ownItems ??= new Set(parseMdlBlocks(text).flatMap(({ id: own, body }) => [...own ? [own] : [], ...reqIds(body)]));
189
+ if (!ownItems.has(item)) report("mdl/ref", from, to, missingItemMessage(id, item));
190
+ continue;
191
+ }
192
+ if (!isReference(id)) continue;
193
+ if (id in index.duplicates) report("mdl/ref", from, to, duplicateSpecMessage(id));
194
+ else if (!(id in index.specs)) report("mdl/ref", from, to, unknownSpecMessage(id));
195
+ else if (!dependencyIds.has(id)) report("mdl/ref", from, to, `\`${id}\` is not a dependency; add \`uses ${id}: …\` under ## Dependencies.`);
196
+ else if (!index.specs[id].items.includes(item)) report("mdl/ref", from, to, missingItemMessage(id, item));
197
+ }
198
+ const changelog = changelogRange(text);
199
+ for (const { from, to } of findSpecKeys(text)) if (!changelog || from < changelog.from || from >= changelog.to) report("mdl/ref", from, to, "Refer to a spec by id (`<id>#<item>`), not by a github: key.");
200
+ return diagnostics;
201
+ };
202
+ /**
203
+ * Lints the text of a Spec .mdl document.
204
+ *
205
+ * Checks:
206
+ * - Unknown block types (first body line of ```mdl blocks) → error
207
+ * - `decision` and `question` attribution (`by:` / `for:` actor prefixes) → error
208
+ * - `mdl/block`: a second block header inside one fence, which every tool reads as body → error
209
+ * - `mdl/ref` and `mdl/uses`: spec references and dependencies, when an index is given → error
210
+ */
211
+ var lintMdl = (text, { index, selfId = frontmatter(text).id } = {}) => {
212
+ const diagnostics = [];
213
+ for (const { type, from, to, body } of parseBlockHeaders(text)) if (type && !KNOWN_BLOCK_TYPES.has(type)) diagnostics.push({
214
+ from,
215
+ to,
216
+ severity: "error",
217
+ source: "mdl/block-type",
218
+ message: `Unknown block type "${type}". Declare it in the Extensions table or define it with an \`ext\` block.`
219
+ });
220
+ else if (type === "decision" || type === "question") for (const message of lintAttribution(body, type === "decision" ? "Decision" : "Question")) diagnostics.push({
221
+ from,
222
+ to,
223
+ severity: "error",
224
+ source: "mdl/decision",
225
+ message
226
+ });
227
+ const types = /* @__PURE__ */ new Set([...BLOCK_TYPES, ...extensionTerms(text)]);
228
+ for (const { type, id, from, to } of findInnerBlockHeaders(text, types)) diagnostics.push({
229
+ from,
230
+ to,
231
+ severity: "error",
232
+ source: "mdl/block",
233
+ message: `A second block header (\`${[type, id].filter(Boolean).join(" ")}\`) inside one fence; give each block its own \`\`\`mdl fence.`
234
+ });
235
+ if (index) diagnostics.push(...lintReferences(text, index, selfId));
236
+ return diagnostics;
237
+ };
238
+ var CHANGELOG_HEADING = /^## Changelog[ \t]*$/m;
239
+ /** The offsets of the `## Changelog` section, up to the next `## ` heading. */
240
+ var changelogRange = (text) => {
241
+ const heading = CHANGELOG_HEADING.exec(text);
242
+ if (!heading) return;
243
+ const after = heading.index + heading[0].length;
244
+ const next = text.slice(after).search(/^## /m);
245
+ return {
246
+ from: heading.index,
247
+ to: next === -1 ? text.length : after + next
248
+ };
249
+ };
250
+ var DECISION_ID = /^D-(\d+)$/;
251
+ var QUESTION_ID = /^Q-(\d+)$/;
252
+ var DECISION_REF = /\[(D-\d+)\]/g;
253
+ var indentOf = (line) => line.length - line.trimStart().length;
254
+ /** A field's value as lines: the inline value, or the indented lines of a `|` block or a `- item` list. */
255
+ var fieldLines = (body, field) => {
256
+ const lines = body.split("\n");
257
+ const index = lines.findIndex((line) => new RegExp(`^\\s+${field}:`).test(line));
258
+ if (index === -1) return;
259
+ const inline = fieldValue(lines[index], field);
260
+ if (inline && inline !== "|" && inline !== ">") return [inline];
261
+ const indent = indentOf(lines[index]);
262
+ const end = lines.findIndex((line, next) => next > index && line.trim() !== "" && indentOf(line) <= indent);
263
+ return lines.slice(index + 1, end === -1 ? void 0 : end).map((line) => line.trim());
264
+ };
265
+ var fieldText = (body, field) => fieldLines(body, field)?.join("\n").trim();
266
+ var parseList = (value) => value?.replace(/^\[|\]$/g, "").split(",").map((item) => item.trim()).filter(Boolean) ?? [];
267
+ var inlineProse = (body) => body.split("\n")[0].replace(/^\w+\s+[^:]*:\s*/, "").trim();
268
+ var parseDecision = ({ id, body }) => {
269
+ const title = inlineProse(body);
270
+ const supersedes = fieldValue(body, "supersedes");
271
+ const why = fieldText(body, "why");
272
+ const context = fieldText(body, "context");
273
+ const refs = [
274
+ title,
275
+ why,
276
+ context
277
+ ].flatMap((prose) => [...(prose ?? "").matchAll(DECISION_REF)].map((match) => match[1])).filter((ref, index, all) => ref !== id && all.indexOf(ref) === index);
278
+ return {
279
+ id,
280
+ text: body.trim(),
281
+ title,
282
+ date: fieldValue(body, "date"),
283
+ by: fieldValue(body, "by"),
284
+ for: fieldValue(body, "for"),
285
+ quote: fieldText(body, "quote"),
286
+ context,
287
+ why,
288
+ source: fieldValue(body, "source"),
289
+ supersedes,
290
+ answers: fieldValue(body, "answers"),
291
+ affects: parseList(fieldValue(body, "affects")),
292
+ refs,
293
+ rejected: (fieldLines(body, "rejected") ?? []).filter(Boolean).map((line) => line.replace(/^-\s*/, ""))
294
+ };
295
+ };
296
+ /** An option line is `<title>: <description>`, or just a title. */
297
+ var parseOption = (line) => {
298
+ const separator = line.indexOf(": ");
299
+ return separator === -1 ? { title: line.trim() } : {
300
+ title: line.slice(0, separator).trim(),
301
+ description: line.slice(separator + 2).trim()
302
+ };
303
+ };
304
+ var parseQuestion = ({ id, body }) => ({
305
+ id,
306
+ text: body.trim(),
307
+ title: inlineProse(body),
308
+ date: fieldValue(body, "date"),
309
+ by: fieldValue(body, "by"),
310
+ for: fieldValue(body, "for"),
311
+ context: fieldText(body, "context"),
312
+ source: fieldValue(body, "source"),
313
+ affects: parseList(fieldValue(body, "affects")),
314
+ options: (fieldLines(body, "options") ?? []).filter((line) => line.startsWith("-")).map((line) => parseOption(line.replace(/^-\s*/, "")))
315
+ });
316
+ /**
317
+ * Splits a spec into its `## Changelog` decisions, its questions, and everything else.
318
+ * The section runs from its heading to the next level-1 or level-2 heading.
319
+ */
320
+ var parseChangelog = (text) => {
321
+ const heading = CHANGELOG_HEADING.exec(text);
322
+ if (!heading) return {
323
+ entries: [],
324
+ questions: [],
325
+ rest: text
326
+ };
327
+ const sectionStart = heading.index;
328
+ const afterHeading = sectionStart + heading[0].length;
329
+ const next = /^#{1,2} /m.exec(text.slice(afterHeading));
330
+ const sectionEnd = next ? afterHeading + next.index : text.length;
331
+ const section = text.slice(sectionStart, sectionEnd);
332
+ const blocks = parseBlockHeaders(section);
333
+ return {
334
+ entries: blocks.filter(({ type }) => type === "decision").map(parseDecision),
335
+ questions: blocks.filter(({ type }) => type === "question").map(parseQuestion),
336
+ rest: text.slice(0, sectionStart) + text.slice(sectionEnd)
337
+ };
338
+ };
339
+ var normalize = (text) => text.split("\n").map((line) => line.trimEnd()).join("\n").trim();
340
+ /** Reported when a spec changed beyond a trivial edit with no new decision; the one error a waiver lifts. */
341
+ var MISSING_DECISION = "The spec changed but no decision was added to `## Changelog`.";
342
+ var TYPO_MAX_WORDS = 3;
343
+ var NORMATIVE_WORDS = /* @__PURE__ */ new Set([
344
+ "all",
345
+ "always",
346
+ "any",
347
+ "can",
348
+ "cannot",
349
+ "every",
350
+ "may",
351
+ "must",
352
+ "never",
353
+ "no",
354
+ "none",
355
+ "not",
356
+ "only",
357
+ "shall",
358
+ "should"
359
+ ]);
360
+ /** Optimal string alignment distance: insertions, deletions, substitutions and adjacent swaps each cost one. */
361
+ var editDistance = (left, right) => {
362
+ const rows = Array.from({ length: left.length + 1 }, (_, row) => Array.from({ length: right.length + 1 }, (_, col) => row === 0 ? col : col === 0 ? row : 0));
363
+ for (let row = 1; row <= left.length; row++) for (let col = 1; col <= right.length; col++) {
364
+ const cost = left[row - 1] === right[col - 1] ? 0 : 1;
365
+ rows[row][col] = Math.min(rows[row - 1][col] + 1, rows[row][col - 1] + 1, rows[row - 1][col - 1] + cost);
366
+ if (row > 1 && col > 1 && left[row - 1] === right[col - 2] && left[row - 2] === right[col - 1]) rows[row][col] = Math.min(rows[row][col], rows[row - 2][col - 2] + 1);
367
+ }
368
+ return rows[left.length][right.length];
369
+ };
370
+ var bareWord = (word) => word.toLowerCase().replace(/[^a-z']/g, "");
371
+ var isTypoFix = (prev, next) => !/\d/.test(prev + next) && !NORMATIVE_WORDS.has(bareWord(prev)) && !NORMATIVE_WORDS.has(bareWord(next)) && editDistance(prev, next) <= Math.floor(Math.max(prev.length, next.length) / 3);
372
+ /**
373
+ * True when `after` differs from `before` only by whitespace or a few small typo fixes, which do not change what
374
+ * the spec requires. Words with digits are ids or numbers, where one character is a different meaning.
375
+ */
376
+ var isTrivialEdit = (before, after) => {
377
+ const prevWords = before.split(/\s+/).filter(Boolean);
378
+ const nextWords = after.split(/\s+/).filter(Boolean);
379
+ if (prevWords.length !== nextWords.length) return false;
380
+ const changed = prevWords.map((word, index) => [word, nextWords[index]]).filter(([prev, next]) => prev !== next);
381
+ return changed.length <= TYPO_MAX_WORDS && changed.every(([prev, next]) => isTypoFix(prev, next));
382
+ };
383
+ /** Questions follow the decisions' append-only rules, with ids of their own sequence. */
384
+ var checkQuestions = (prev, next) => {
385
+ const errors = [];
386
+ const ids = next.map(({ id }) => id);
387
+ for (const id of ids) if (!QUESTION_ID.test(id)) errors.push(`Question id \`${id}\` must be \`Q-<n>\`.`);
388
+ for (const id of new Set(ids.filter((id, index) => ids.indexOf(id) !== index))) errors.push(`Question ${id} appears more than once.`);
389
+ const nextById = new Map(next.map((question) => [question.id, question]));
390
+ for (const { id, text } of prev) {
391
+ const current = nextById.get(id);
392
+ if (!current) errors.push(`Question ${id} was removed — the changelog is append-only; answer it with a decision instead.`);
393
+ else if (normalize(current.text) !== normalize(text)) errors.push(`Question ${id} was edited — the changelog is append-only; ask a new question instead.`);
394
+ }
395
+ const prevIds = new Set(prev.map(({ id }) => id));
396
+ let expected = Math.max(0, ...prev.map(({ id }) => Number(QUESTION_ID.exec(id)?.[1] ?? 0))) + 1;
397
+ for (const { id } of next.filter(({ id }) => !prevIds.has(id))) {
398
+ if (id !== `Q-${expected}`) errors.push(`Question ${id} is out of sequence — the next id is Q-${expected}.`);
399
+ expected++;
400
+ }
401
+ return errors;
402
+ };
403
+ /**
404
+ * Checks one spec change against the changelog rules: every change except a trivial edit adds a decision, and the
405
+ * log is append-only with monotonic ids. `before` is undefined for a new spec.
406
+ */
407
+ var checkChangelogChange = (before, after) => {
408
+ const errors = [];
409
+ const prev = before === void 0 ? {
410
+ entries: [],
411
+ questions: [],
412
+ rest: ""
413
+ } : parseChangelog(before);
414
+ const next = parseChangelog(after);
415
+ const ids = next.entries.map(({ id }) => id);
416
+ for (const id of ids) if (!DECISION_ID.test(id)) errors.push(`Decision id \`${id}\` must be \`D-<n>\`.`);
417
+ const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index);
418
+ for (const id of new Set(duplicates)) errors.push(`Decision ${id} appears more than once.`);
419
+ const nextById = new Map(next.entries.map((entry) => [entry.id, entry]));
420
+ for (const { id, text } of prev.entries) {
421
+ const current = nextById.get(id);
422
+ if (!current) errors.push(`Decision ${id} was removed — the changelog is append-only; supersede it instead.`);
423
+ else if (normalize(current.text) !== normalize(text)) errors.push(`Decision ${id} was edited — the changelog is append-only; supersede it instead.`);
424
+ }
425
+ const prevIds = new Set(prev.entries.map(({ id }) => id));
426
+ const added = next.entries.filter(({ id }) => !prevIds.has(id));
427
+ const kept = ids.filter((id) => prevIds.has(id));
428
+ const firstAdded = ids.findIndex((id) => !prevIds.has(id));
429
+ if (!(kept.join() === prev.entries.filter(({ id }) => nextById.has(id)).map(({ id }) => id).join()) || firstAdded !== -1 && ids.slice(firstAdded).some((id) => prevIds.has(id))) errors.push("Decisions must stay in order, with new ones appended last.");
430
+ let expected = Math.max(0, ...prev.entries.map(({ id }) => Number(DECISION_ID.exec(id)?.[1] ?? 0))) + 1;
431
+ for (const { id } of added) {
432
+ if (id !== `D-${expected}`) errors.push(`Decision ${id} is out of sequence — the next id is D-${expected}.`);
433
+ expected++;
434
+ }
435
+ for (const { id, supersedes } of next.entries) if (supersedes !== void 0 && !nextById.has(supersedes)) errors.push(`Decision ${id} supersedes ${supersedes}, which is not in the changelog.`);
436
+ errors.push(...checkQuestions(prev.questions, next.questions));
437
+ const questionIds = new Set(next.questions.map(({ id }) => id));
438
+ const answeredBy = /* @__PURE__ */ new Map();
439
+ for (const { id, answers, supersedes } of next.entries) {
440
+ if (answers === void 0) continue;
441
+ const first = answeredBy.get(answers);
442
+ if (!questionIds.has(answers)) errors.push(`Decision ${id} answers ${answers}, which is not in the changelog.`);
443
+ else if (first !== void 0 && supersedes !== first) errors.push(`Decision ${id} answers ${answers}, which ${first} already answered — supersede ${first} instead.`);
444
+ else answeredBy.set(answers, id);
445
+ }
446
+ if (added.length === 0 && (before === void 0 || !isTrivialEdit(prev.rest, next.rest))) errors.push(before === void 0 ? "A new spec needs a `## Changelog` with at least one decision." : MISSING_DECISION);
447
+ return errors;
448
+ };
449
+ //#endregion
450
+ export { lintMdl as a, specReferenceFilter as c, findSpecRefs as d, scanSpecLines as f, isTrivialEdit as i, unknownSpecMessage as l, BLOCK_TYPES as m, checkChangelogChange as n, missingItemMessage as o, specDependencies as p, duplicateSpecMessage as r, parseChangelog as s, MISSING_DECISION as t, findSpecKeys as u };
451
+
452
+ //# sourceMappingURL=chunk-check.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-check.mjs","names":[],"sources":["../../src/extension/constants.ts","../../src/extension/refs.ts","../../src/extension/check.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Known Spec block types from the core + standard dialect.\n * In future this will be derived from the Extensions table in the document.\n */\nexport const BLOCK_TYPES = [\n 'ext',\n 'type',\n 'op',\n 'feat',\n 'feature',\n 'scenario',\n 'test',\n 'component',\n 'service',\n 'db',\n 'module',\n 'suite',\n 'decision',\n 'question',\n 'verdict',\n 'plugin',\n 'uses',\n 'table',\n] as const;\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { parseMdlBlocks, scanFenceLines } from './blocks.ts';\n\n/** A `<spec id>#<item>` reference, with the offsets of the whole reference text. */\nexport type SpecRef = { id: string; item: string; from: number; to: number };\n\n/** A spec this one depends on, with the offsets of the id text. */\nexport type Dependency = { id: string; via: 'uses' | 'dependsOn'; from: number; to: number };\n\n// The lookbehind rejects `github:org/repo/file.mdl#X` keys and URL fragments; the final `\\w` drops a sentence period.\n// Segments after the first may be camelCase, as plugin ids are (`org.dxos.plugin.fileSystem`).\nconst REF = /(?<![\\w/:.#-])([a-z][a-z0-9-]*(?:\\.[a-zA-Z0-9-]+)+)#([\\w$.-]*\\w)/g;\n\n/**\n * Calls `visit` for each line of prose and of `mdl` fences, with the line's offset in the text.\n * Every other fenced block is skipped, since it holds code rather than spec text.\n */\nexport const scanSpecLines = (text: string, visit: (line: string, offset: number) => void): void =>\n scanFenceLines(text, ({ line, offset, kind, mdl }) => {\n if (kind === 'prose' || (kind === 'body' && mdl)) {\n visit(line, offset);\n }\n });\n\n/** Finds `<spec id>#<item>` references in prose and in `mdl` fences (comments included). */\nexport const findSpecRefs = (text: string): SpecRef[] => {\n const refs: SpecRef[] = [];\n scanSpecLines(text, (line, offset) => {\n for (const match of line.matchAll(REF)) {\n const from = offset + match.index;\n refs.push({ id: match[1], item: match[2], from, to: from + match[0].length });\n }\n });\n return refs;\n};\n\nconst GITHUB_SPEC_KEY = /github:[^\\s`'\")\\]>,]*?\\.mdl(?![\\w/-]|\\.\\w)(?:#[\\w$.-]*)?/g;\n\n/** Finds `github:` keys that point at a `.mdl` file, with the offsets of the whole key. */\nexport const findSpecKeys = (text: string): { from: number; to: number }[] => {\n const keys: { from: number; to: number }[] = [];\n scanSpecLines(text, (line, offset) => {\n for (const match of line.matchAll(GITHUB_SPEC_KEY)) {\n keys.push({ from: offset + match.index, to: offset + match.index + match[0].length });\n }\n });\n return keys;\n};\n\n/**\n * The specs this one depends on: every `uses` block id and every entry of the `plugin` block's\n * `dependsOn: [...]`, in document order.\n */\nexport const specDependencies = (text: string): Dependency[] => {\n const deps: Dependency[] = [];\n for (const { type, id, from, body } of parseMdlBlocks(text)) {\n const headerStart = text.indexOf('\\n', from) + 1;\n const bodyStart = text.indexOf('\\n', headerStart) + 1;\n if (type === 'uses' && id) {\n const idFrom = text.indexOf(id, headerStart + text.slice(headerStart).search(/\\S/) + type.length);\n deps.push({ id, via: 'uses', from: idFrom, to: idFrom + id.length });\n } else if (type === 'plugin') {\n let lineFrom = bodyStart;\n let inList = false;\n for (const line of body.split('\\n')) {\n const field = line.match(/^[ \\t]+dependsOn:[ \\t]*(.*?)[ \\t]*$/);\n if (field) {\n const inline = field[1].match(/^\\[([^\\]]*)\\]/);\n inList = field[1] === '' || field[1].startsWith('#');\n if (inline) {\n const listFrom = lineFrom + line.indexOf('[', line.indexOf('dependsOn:')) + 1;\n for (const entry of inline[1].matchAll(/[^\\s,]+/g)) {\n const idFrom = listFrom + entry.index;\n deps.push({ id: entry[0], via: 'dependsOn', from: idFrom, to: idFrom + entry[0].length });\n }\n }\n } else if (inList) {\n const item = line.match(/^[ \\t]+-[ \\t]+([^\\s#]+)/);\n if (item) {\n const idFrom = lineFrom + line.indexOf(item[1]);\n deps.push({ id: item[1], via: 'dependsOn', from: idFrom, to: idFrom + item[1].length });\n } else if (line.trim() !== '') {\n inList = false;\n }\n }\n lineFrom += line.length + 1;\n }\n }\n }\n return deps;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Diagnostic } from '@codemirror/lint';\n\nimport { frontmatter, reqIds } from '../spec-index/parse.ts';\nimport { type SpecIndex } from '../spec-index/spec-index.ts';\nimport {\n type BlockHeader,\n extensionTerms,\n findInnerBlockHeaders,\n parseBlockHeaders,\n parseMdlBlocks,\n} from './blocks.ts';\nimport { BLOCK_TYPES } from './constants.ts';\nimport { findSpecKeys, findSpecRefs, specDependencies } from './refs.ts';\n\nconst KNOWN_BLOCK_TYPES = new Set(BLOCK_TYPES);\n\nconst USER_REF = /^user:\\S+$/;\nconst AGENT_REF = /^agent:\\S+$/;\n\nconst fieldValue = (body: string, field: string): string | undefined =>\n body.match(new RegExp(`^\\\\s+${field}:[ \\\\t]*(.*?)[ \\\\t]*(?:#.*)?$`, 'm'))?.[1];\n\n/**\n * Checks the attribution rules of the changelog dialect (`lang/changelog.mdl`), which keep\n * decisions made by people and decisions made by agents separable. A `question` is attributed the same way.\n */\nconst lintAttribution = (body: string, noun: 'Decision' | 'Question'): string[] => {\n const errors: string[] = [];\n const by = fieldValue(body, 'by');\n const principal = fieldValue(body, 'for');\n if (!by) {\n errors.push(`${noun} is missing \\`by:\\` — name the user: or agent: that made it.`);\n } else if (AGENT_REF.test(by)) {\n if (!principal) {\n errors.push(`Agent ${noun.toLowerCase()} is missing \\`for:\\` — name the user: the agent acted for.`);\n }\n } else if (USER_REF.test(by)) {\n if (principal !== undefined) {\n errors.push(`\\`for:\\` applies only to agent ${noun.toLowerCase()}s.`);\n }\n } else {\n errors.push(`${noun} \\`by: ${by}\\` must be \\`user:<handle>\\` or \\`agent:<name>\\`.`);\n }\n if (principal && !USER_REF.test(principal)) {\n errors.push(`\\`for: ${principal}\\` must be \\`user:<handle>\\`.`);\n }\n return errors;\n};\n\nexport type LintOptions = {\n /** Enables `mdl/ref` and `mdl/uses`, which need every other spec to resolve against. */\n index?: SpecIndex;\n /** The spec's own id; defaults to the frontmatter `id`. */\n selfId?: string;\n};\n\nconst namespace = (id: string): string => id.split('.').slice(0, 2).join('.');\n\n/** Lint message for an id the index does not hold. */\nexport const unknownSpecMessage = (id: string): string => `Unknown spec \\`${id}\\`.`;\n\n/** Lint message for a reference to an item the spec does not declare. */\nexport const missingItemMessage = (id: string, item: string): string => `\\`${id}\\` has no item \\`${item}\\`.`;\n\n/** Lint message for an id more than one file claims. */\nexport const duplicateSpecMessage = (id: string): string => `Spec id \\`${id}\\` is declared by more than one file.`;\n\n/**\n * Whether a `<id>#<item>` candidate is a spec reference rather than prose (a file name, an external schema id):\n * its id is indexed, or shares its first two dotted segments with an indexed id.\n */\nexport const specReferenceFilter = (index: SpecIndex): ((id: string) => boolean) => {\n const namespaces = new Set([...Object.keys(index.specs), ...Object.keys(index.duplicates)].map(namespace));\n return (id) => namespaces.has(namespace(id));\n};\n\nconst lintReferences = (text: string, index: SpecIndex, selfId: string | undefined): Diagnostic[] => {\n const diagnostics: Diagnostic[] = [];\n const report = (source: string, from: number, to: number, message: string) =>\n diagnostics.push({ from, to, severity: 'error', source, message });\n const dependencies = specDependencies(text);\n const dependsOn = new Set(dependencies.filter(({ via }) => via === 'dependsOn').map(({ id }) => id));\n const declared = new Set<string>();\n\n if (selfId && selfId in index.duplicates) {\n const idLine = /^id:.*$/m.exec(text);\n report(\n 'mdl/uses',\n idLine?.index ?? 0,\n (idLine?.index ?? 0) + (idLine?.[0].length ?? 0),\n duplicateSpecMessage(selfId),\n );\n }\n\n for (const { id, via, from, to } of dependencies) {\n if (id === selfId) {\n report('mdl/uses', from, to, 'A spec cannot use itself.');\n } else if (id in index.duplicates) {\n report('mdl/uses', from, to, duplicateSpecMessage(id));\n } else if (!(id in index.specs)) {\n report('mdl/uses', from, to, unknownSpecMessage(id));\n } else if (via === 'uses' && dependsOn.has(id)) {\n report('mdl/uses', from, to, `\\`${id}\\` is in dependsOn; do not repeat it under uses.`);\n } else if (declared.has(id)) {\n report('mdl/uses', from, to, `\\`${id}\\` is declared twice.`);\n }\n declared.add(id);\n }\n\n const isReference = specReferenceFilter(index);\n const dependencyIds = new Set(dependencies.map(({ id }) => id));\n // The spec's own items come from its text, since the index may predate the edit being linted.\n let ownItems: Set<string> | undefined;\n for (const { id, item, from, to } of findSpecRefs(text)) {\n if (id === selfId) {\n ownItems ??= new Set(\n parseMdlBlocks(text).flatMap(({ id: own, body }) => [...(own ? [own] : []), ...reqIds(body)]),\n );\n if (!ownItems.has(item)) {\n report('mdl/ref', from, to, missingItemMessage(id, item));\n }\n continue;\n }\n if (!isReference(id)) {\n continue;\n }\n if (id in index.duplicates) {\n report('mdl/ref', from, to, duplicateSpecMessage(id));\n } else if (!(id in index.specs)) {\n report('mdl/ref', from, to, unknownSpecMessage(id));\n } else if (!dependencyIds.has(id)) {\n report('mdl/ref', from, to, `\\`${id}\\` is not a dependency; add \\`uses ${id}: …\\` under ## Dependencies.`);\n } else if (!index.specs[id].items.includes(item)) {\n report('mdl/ref', from, to, missingItemMessage(id, item));\n }\n }\n\n // The changelog is append-only, so a decision that predates this rule keeps the key it was written with.\n const changelog = changelogRange(text);\n for (const { from, to } of findSpecKeys(text)) {\n if (!changelog || from < changelog.from || from >= changelog.to) {\n report('mdl/ref', from, to, 'Refer to a spec by id (`<id>#<item>`), not by a github: key.');\n }\n }\n return diagnostics;\n};\n\n/**\n * Lints the text of a Spec .mdl document.\n *\n * Checks:\n * - Unknown block types (first body line of ```mdl blocks) → error\n * - `decision` and `question` attribution (`by:` / `for:` actor prefixes) → error\n * - `mdl/block`: a second block header inside one fence, which every tool reads as body → error\n * - `mdl/ref` and `mdl/uses`: spec references and dependencies, when an index is given → error\n */\nexport const lintMdl = (text: string, { index, selfId = frontmatter(text).id }: LintOptions = {}): Diagnostic[] => {\n const diagnostics: Diagnostic[] = [];\n for (const { type, from, to, body } of parseBlockHeaders(text)) {\n if (type && !KNOWN_BLOCK_TYPES.has(type as (typeof BLOCK_TYPES)[number])) {\n diagnostics.push({\n from,\n to,\n severity: 'error',\n source: 'mdl/block-type',\n message: `Unknown block type \"${type}\". Declare it in the Extensions table or define it with an \\`ext\\` block.`,\n });\n } else if (type === 'decision' || type === 'question') {\n for (const message of lintAttribution(body, type === 'decision' ? 'Decision' : 'Question')) {\n diagnostics.push({ from, to, severity: 'error', source: 'mdl/decision', message });\n }\n }\n }\n const types = new Set<string>([...BLOCK_TYPES, ...extensionTerms(text)]);\n for (const { type, id, from, to } of findInnerBlockHeaders(text, types)) {\n diagnostics.push({\n from,\n to,\n severity: 'error',\n source: 'mdl/block',\n message: `A second block header (\\`${[type, id].filter(Boolean).join(' ')}\\`) inside one fence; give each block its own \\`\\`\\`mdl fence.`,\n });\n }\n if (index) {\n diagnostics.push(...lintReferences(text, index, selfId));\n }\n\n return diagnostics;\n};\n\n/** One `decision` block of a spec's `## Changelog`, with the fields of `lang/changelog.mdl` it carries. */\nexport type ChangelogEntry = {\n id: string;\n /** The whole block body, for comparing entries. */\n text: string;\n /** The decision itself: the inline prose after `decision D-n:`. */\n title: string;\n date?: string;\n /** The decider, `user:<handle>` or `agent:<name>`. */\n by?: string;\n /** The person an agent acted for. */\n for?: string;\n quote?: string;\n context?: string;\n why?: string;\n source?: string;\n supersedes?: string;\n /** The question this decision answers. */\n answers?: string;\n /** Block ids the decision constrains. */\n affects: string[];\n /** Other decisions the prose cites as `[D-n]`, in order of first mention. */\n refs: string[];\n rejected: string[];\n};\n\n/** One suggested answer of a `question`. */\nexport type QuestionOption = { title: string; description?: string };\n\n/** One `question` block of a spec's `## Changelog`: a choice nobody has made yet (`lang/changelog.mdl` rule 10). */\nexport type ChangelogQuestion = {\n id: string;\n /** The whole block body, for comparing entries. */\n text: string;\n /** The question itself: the inline prose after `question Q-n:`. */\n title: string;\n date?: string;\n /** The asker, `user:<handle>` or `agent:<name>`. */\n by?: string;\n /** The person an agent asked for. */\n for?: string;\n context?: string;\n source?: string;\n /** Block ids the answer will constrain. */\n affects: string[];\n options: QuestionOption[];\n};\n\nconst CHANGELOG_HEADING = /^## Changelog[ \\t]*$/m;\n\n/** The offsets of the `## Changelog` section, up to the next `## ` heading. */\nconst changelogRange = (text: string): { from: number; to: number } | undefined => {\n const heading = CHANGELOG_HEADING.exec(text);\n if (!heading) {\n return undefined;\n }\n const after = heading.index + heading[0].length;\n const next = text.slice(after).search(/^## /m);\n return { from: heading.index, to: next === -1 ? text.length : after + next };\n};\nconst DECISION_ID = /^D-(\\d+)$/;\nconst QUESTION_ID = /^Q-(\\d+)$/;\nconst DECISION_REF = /\\[(D-\\d+)\\]/g;\n\nconst indentOf = (line: string): number => line.length - line.trimStart().length;\n\n/** A field's value as lines: the inline value, or the indented lines of a `|` block or a `- item` list. */\nconst fieldLines = (body: string, field: string): string[] | undefined => {\n const lines = body.split('\\n');\n const index = lines.findIndex((line) => new RegExp(`^\\\\s+${field}:`).test(line));\n if (index === -1) {\n return undefined;\n }\n const inline = fieldValue(lines[index], field);\n if (inline && inline !== '|' && inline !== '>') {\n return [inline];\n }\n const indent = indentOf(lines[index]);\n const end = lines.findIndex((line, next) => next > index && line.trim() !== '' && indentOf(line) <= indent);\n return lines.slice(index + 1, end === -1 ? undefined : end).map((line) => line.trim());\n};\n\nconst fieldText = (body: string, field: string): string | undefined => fieldLines(body, field)?.join('\\n').trim();\n\nconst parseList = (value: string | undefined): string[] =>\n value\n ?.replace(/^\\[|\\]$/g, '')\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean) ?? [];\n\nconst inlineProse = (body: string): string =>\n body\n .split('\\n')[0]\n .replace(/^\\w+\\s+[^:]*:\\s*/, '')\n .trim();\n\nconst parseDecision = ({ id, body }: BlockHeader): ChangelogEntry => {\n const title = inlineProse(body);\n const supersedes = fieldValue(body, 'supersedes');\n const why = fieldText(body, 'why');\n const context = fieldText(body, 'context');\n const refs = [title, why, context]\n .flatMap((prose) => [...(prose ?? '').matchAll(DECISION_REF)].map((match) => match[1]))\n .filter((ref, index, all) => ref !== id && all.indexOf(ref) === index);\n return {\n id,\n text: body.trim(),\n title,\n date: fieldValue(body, 'date'),\n by: fieldValue(body, 'by'),\n for: fieldValue(body, 'for'),\n quote: fieldText(body, 'quote'),\n context,\n why,\n source: fieldValue(body, 'source'),\n supersedes,\n answers: fieldValue(body, 'answers'),\n affects: parseList(fieldValue(body, 'affects')),\n refs,\n rejected: (fieldLines(body, 'rejected') ?? []).filter(Boolean).map((line) => line.replace(/^-\\s*/, '')),\n };\n};\n\n/** An option line is `<title>: <description>`, or just a title. */\nconst parseOption = (line: string): QuestionOption => {\n const separator = line.indexOf(': ');\n return separator === -1\n ? { title: line.trim() }\n : { title: line.slice(0, separator).trim(), description: line.slice(separator + 2).trim() };\n};\n\nconst parseQuestion = ({ id, body }: BlockHeader): ChangelogQuestion => ({\n id,\n text: body.trim(),\n title: inlineProse(body),\n date: fieldValue(body, 'date'),\n by: fieldValue(body, 'by'),\n for: fieldValue(body, 'for'),\n context: fieldText(body, 'context'),\n source: fieldValue(body, 'source'),\n affects: parseList(fieldValue(body, 'affects')),\n options: (fieldLines(body, 'options') ?? [])\n .filter((line) => line.startsWith('-'))\n .map((line) => parseOption(line.replace(/^-\\s*/, ''))),\n});\n\n/**\n * Splits a spec into its `## Changelog` decisions, its questions, and everything else.\n * The section runs from its heading to the next level-1 or level-2 heading.\n */\nexport const parseChangelog = (\n text: string,\n): { entries: ChangelogEntry[]; questions: ChangelogQuestion[]; rest: string } => {\n const heading = CHANGELOG_HEADING.exec(text);\n if (!heading) {\n return { entries: [], questions: [], rest: text };\n }\n const sectionStart = heading.index;\n const afterHeading = sectionStart + heading[0].length;\n const next = /^#{1,2} /m.exec(text.slice(afterHeading));\n const sectionEnd = next ? afterHeading + next.index : text.length;\n const section = text.slice(sectionStart, sectionEnd);\n const blocks = parseBlockHeaders(section);\n const entries = blocks.filter(({ type }) => type === 'decision').map(parseDecision);\n const questions = blocks.filter(({ type }) => type === 'question').map(parseQuestion);\n return { entries, questions, rest: text.slice(0, sectionStart) + text.slice(sectionEnd) };\n};\n\nconst normalize = (text: string): string =>\n text\n .split('\\n')\n .map((line) => line.trimEnd())\n .join('\\n')\n .trim();\n\n/** Reported when a spec changed beyond a trivial edit with no new decision; the one error a waiver lifts. */\nexport const MISSING_DECISION = 'The spec changed but no decision was added to `## Changelog`.';\n\nconst TYPO_MAX_WORDS = 3;\n\n// One letter in these flips what a requirement says (must/most, can/can't), so they are never a typo fix.\nconst NORMATIVE_WORDS = new Set([\n 'all',\n 'always',\n 'any',\n 'can',\n 'cannot',\n 'every',\n 'may',\n 'must',\n 'never',\n 'no',\n 'none',\n 'not',\n 'only',\n 'shall',\n 'should',\n]);\n\n/** Optimal string alignment distance: insertions, deletions, substitutions and adjacent swaps each cost one. */\nconst editDistance = (left: string, right: string): number => {\n const rows = Array.from({ length: left.length + 1 }, (_, row) =>\n Array.from({ length: right.length + 1 }, (_, col) => (row === 0 ? col : col === 0 ? row : 0)),\n );\n for (let row = 1; row <= left.length; row++) {\n for (let col = 1; col <= right.length; col++) {\n const cost = left[row - 1] === right[col - 1] ? 0 : 1;\n rows[row][col] = Math.min(rows[row - 1][col] + 1, rows[row][col - 1] + 1, rows[row - 1][col - 1] + cost);\n if (row > 1 && col > 1 && left[row - 1] === right[col - 2] && left[row - 2] === right[col - 1]) {\n rows[row][col] = Math.min(rows[row][col], rows[row - 2][col - 2] + 1);\n }\n }\n }\n return rows[left.length][right.length];\n};\n\nconst bareWord = (word: string): string => word.toLowerCase().replace(/[^a-z']/g, '');\n\nconst isTypoFix = (prev: string, next: string): boolean =>\n !/\\d/.test(prev + next) &&\n !NORMATIVE_WORDS.has(bareWord(prev)) &&\n !NORMATIVE_WORDS.has(bareWord(next)) &&\n editDistance(prev, next) <= Math.floor(Math.max(prev.length, next.length) / 3);\n\n/**\n * True when `after` differs from `before` only by whitespace or a few small typo fixes, which do not change what\n * the spec requires. Words with digits are ids or numbers, where one character is a different meaning.\n */\nexport const isTrivialEdit = (before: string, after: string): boolean => {\n const prevWords = before.split(/\\s+/).filter(Boolean);\n const nextWords = after.split(/\\s+/).filter(Boolean);\n if (prevWords.length !== nextWords.length) {\n return false;\n }\n const changed = prevWords\n .map((word, index) => [word, nextWords[index]] as const)\n .filter(([prev, next]) => prev !== next);\n return changed.length <= TYPO_MAX_WORDS && changed.every(([prev, next]) => isTypoFix(prev, next));\n};\n\n/** Questions follow the decisions' append-only rules, with ids of their own sequence. */\nconst checkQuestions = (prev: readonly ChangelogQuestion[], next: readonly ChangelogQuestion[]): string[] => {\n const errors: string[] = [];\n const ids = next.map(({ id }) => id);\n for (const id of ids) {\n if (!QUESTION_ID.test(id)) {\n errors.push(`Question id \\`${id}\\` must be \\`Q-<n>\\`.`);\n }\n }\n for (const id of new Set(ids.filter((id, index) => ids.indexOf(id) !== index))) {\n errors.push(`Question ${id} appears more than once.`);\n }\n\n const nextById = new Map(next.map((question) => [question.id, question]));\n for (const { id, text } of prev) {\n const current = nextById.get(id);\n if (!current) {\n errors.push(`Question ${id} was removed — the changelog is append-only; answer it with a decision instead.`);\n } else if (normalize(current.text) !== normalize(text)) {\n errors.push(`Question ${id} was edited — the changelog is append-only; ask a new question instead.`);\n }\n }\n\n const prevIds = new Set(prev.map(({ id }) => id));\n let expected = Math.max(0, ...prev.map(({ id }) => Number(QUESTION_ID.exec(id)?.[1] ?? 0))) + 1;\n for (const { id } of next.filter(({ id }) => !prevIds.has(id))) {\n if (id !== `Q-${expected}`) {\n errors.push(`Question ${id} is out of sequence — the next id is Q-${expected}.`);\n }\n expected++;\n }\n return errors;\n};\n\n/**\n * Checks one spec change against the changelog rules: every change except a trivial edit adds a decision, and the\n * log is append-only with monotonic ids. `before` is undefined for a new spec.\n */\nexport const checkChangelogChange = (before: string | undefined, after: string): string[] => {\n const errors: string[] = [];\n const prev = before === undefined ? { entries: [], questions: [], rest: '' } : parseChangelog(before);\n const next = parseChangelog(after);\n\n const ids = next.entries.map(({ id }) => id);\n for (const id of ids) {\n if (!DECISION_ID.test(id)) {\n errors.push(`Decision id \\`${id}\\` must be \\`D-<n>\\`.`);\n }\n }\n const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index);\n for (const id of new Set(duplicates)) {\n errors.push(`Decision ${id} appears more than once.`);\n }\n\n const nextById = new Map(next.entries.map((entry) => [entry.id, entry]));\n for (const { id, text } of prev.entries) {\n const current = nextById.get(id);\n if (!current) {\n errors.push(`Decision ${id} was removed — the changelog is append-only; supersede it instead.`);\n } else if (normalize(current.text) !== normalize(text)) {\n errors.push(`Decision ${id} was edited — the changelog is append-only; supersede it instead.`);\n }\n }\n\n const prevIds = new Set(prev.entries.map(({ id }) => id));\n const added = next.entries.filter(({ id }) => !prevIds.has(id));\n const kept = ids.filter((id) => prevIds.has(id));\n const firstAdded = ids.findIndex((id) => !prevIds.has(id));\n const keptInOrder =\n kept.join() ===\n prev.entries\n .filter(({ id }) => nextById.has(id))\n .map(({ id }) => id)\n .join();\n if (!keptInOrder || (firstAdded !== -1 && ids.slice(firstAdded).some((id) => prevIds.has(id)))) {\n errors.push('Decisions must stay in order, with new ones appended last.');\n }\n\n let expected = Math.max(0, ...prev.entries.map(({ id }) => Number(DECISION_ID.exec(id)?.[1] ?? 0))) + 1;\n for (const { id } of added) {\n if (id !== `D-${expected}`) {\n errors.push(`Decision ${id} is out of sequence — the next id is D-${expected}.`);\n }\n expected++;\n }\n\n for (const { id, supersedes } of next.entries) {\n if (supersedes !== undefined && !nextById.has(supersedes)) {\n errors.push(`Decision ${id} supersedes ${supersedes}, which is not in the changelog.`);\n }\n }\n\n errors.push(...checkQuestions(prev.questions, next.questions));\n const questionIds = new Set(next.questions.map(({ id }) => id));\n const answeredBy = new Map<string, string>();\n for (const { id, answers, supersedes } of next.entries) {\n if (answers === undefined) {\n continue;\n }\n const first = answeredBy.get(answers);\n if (!questionIds.has(answers)) {\n errors.push(`Decision ${id} answers ${answers}, which is not in the changelog.`);\n } else if (first !== undefined && supersedes !== first) {\n errors.push(`Decision ${id} answers ${answers}, which ${first} already answered — supersede ${first} instead.`);\n } else {\n answeredBy.set(answers, id);\n }\n }\n\n if (added.length === 0 && (before === undefined || !isTrivialEdit(prev.rest, next.rest))) {\n errors.push(\n before === undefined ? 'A new spec needs a `## Changelog` with at least one decision.' : MISSING_DECISION,\n );\n }\n\n return errors;\n};\n"],"mappings":";;;;;;;AAQA,IAAa,cAAc;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;ACbA,IAAM,MAAM;;;;;AAMZ,IAAa,iBAAiB,MAAc,UAC1C,eAAe,OAAO,EAAE,MAAM,QAAQ,MAAM,UAAU;CACpD,IAAI,SAAS,WAAY,SAAS,UAAU,KAC1C,MAAM,MAAM,MAAM;AAEtB,CAAC;;AAGH,IAAa,gBAAgB,SAA4B;CACvD,MAAM,OAAkB,CAAC;CACzB,cAAc,OAAO,MAAM,WAAW;EACpC,KAAK,MAAM,SAAS,KAAK,SAAS,GAAG,GAAG;GACtC,MAAM,OAAO,SAAS,MAAM;GAC5B,KAAK,KAAK;IAAE,IAAI,MAAM;IAAI,MAAM,MAAM;IAAI;IAAM,IAAI,OAAO,MAAM,EAAE,CAAC;GAAO,CAAC;EAC9E;CACF,CAAC;CACD,OAAO;AACT;AAEA,IAAM,kBAAkB;;AAGxB,IAAa,gBAAgB,SAAiD;CAC5E,MAAM,OAAuC,CAAC;CAC9C,cAAc,OAAO,MAAM,WAAW;EACpC,KAAK,MAAM,SAAS,KAAK,SAAS,eAAe,GAC/C,KAAK,KAAK;GAAE,MAAM,SAAS,MAAM;GAAO,IAAI,SAAS,MAAM,QAAQ,MAAM,EAAE,CAAC;EAAO,CAAC;CAExF,C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AK,MAAM,EAAE,QAAQ,OAAO;EAC1B,IAAI,OAAO,KAAK,YACd,OAAO,KAAK,YAAY,GAAG,yCAAyC,SAAS,EAAE;EAEjF;CACF;CAEA,KAAK,MAAM,EAAE,IAAI,gBAAgB,KAAK,SACpC,IAAI,eAAe,KAAA,KAAa,CAAC,SAAS,IAAI,UAAU,GACtD,OAAO,KAAK,YAAY,GAAG,cAAc,WAAW,iCAAiC;CAIzF,OAAO,KAAK,GAAG,eAAe,KAAK,WAAW,KAAK,SAAS,CAAC;CAC7D,MAAM,cAAc,IAAI,IAAI,KAAK,UAAU,KAAK,EAAE,SAAS,EAAE,CAAC;CAC9D,MAAM,6BAAa,IAAI,IAAoB;CAC3C,KAAK,MAAM,EAAE,IAAI,SAAS,gBAAgB,KAAK,SAAS;EACtD,IAAI,YAAY,KAAA,GACd;EAEF,MAAM,QAAQ,WAAW,IAAI,OAAO;EACpC,IAAI,CAAC,YAAY,IAAI,OAAO,GAC1B,OAAO,KAAK,YAAY,GAAG,WAAW,QAAQ,iCAAiC;OAC1E,IAAI,UAAU,KAAA,KAAa,eAAe,OAC/C,OAAO,KAAK,YAAY,GAAG,WAAW,QAAQ,UAAU,MAAM,gCAAgC,MAAM,UAAU;OAE9G,WAAW,IAAI,SAAS,EAAE;CAE9B;CAEA,IAAI,MAAM,WAAW,MAAM,WAAW,KAAA,KAAa,CAAC,cAAc,KAAK,MAAM,KAAK,IAAI,IACpF,OAAO,KACL,WAAW,KAAA,IAAY,kEAAkE,gBAC3F;CAGF,OAAO;AACT"}
@@ -0,0 +1,112 @@
1
+ import { n as FENCE_REGEX } from "./chunk-blocks.mjs";
2
+ //#region src/extension/completion.ts
3
+ var BLOCK_FIELDS = {
4
+ ext: [
5
+ "uri",
6
+ "desc",
7
+ "extends",
8
+ "fields",
9
+ "adds-fields",
10
+ "nesting",
11
+ "inline-prose",
12
+ "example"
13
+ ],
14
+ type: [
15
+ "desc",
16
+ "fields",
17
+ "literals",
18
+ "extends"
19
+ ],
20
+ op: [
21
+ "desc",
22
+ "input",
23
+ "output",
24
+ "errors",
25
+ "effects",
26
+ "requires",
27
+ "invariants",
28
+ "note"
29
+ ],
30
+ feat: ["desc", "req"],
31
+ test: [
32
+ "given",
33
+ "when",
34
+ "then",
35
+ "tags"
36
+ ],
37
+ component: [
38
+ "desc",
39
+ "props",
40
+ "state",
41
+ "slots",
42
+ "actions",
43
+ "emits",
44
+ "layout"
45
+ ],
46
+ service: [
47
+ "desc",
48
+ "loading",
49
+ "ops",
50
+ "errors",
51
+ "note"
52
+ ],
53
+ db: [
54
+ "desc",
55
+ "backend",
56
+ "entities",
57
+ "queries",
58
+ "note"
59
+ ],
60
+ module: [
61
+ "desc",
62
+ "api",
63
+ "styleguide"
64
+ ],
65
+ decision: [
66
+ "date",
67
+ "by",
68
+ "for",
69
+ "affects",
70
+ "supersedes",
71
+ "answers",
72
+ "why",
73
+ "rejected",
74
+ "source"
75
+ ],
76
+ question: [
77
+ "date",
78
+ "by",
79
+ "for",
80
+ "affects",
81
+ "context",
82
+ "options",
83
+ "source"
84
+ ]
85
+ };
86
+ /**
87
+ * The fields a cursor at `pos` may complete: inside an `mdl` fence, past its header line, before any `:` on the line.
88
+ * Undefined anywhere else, or in a block whose type has no known fields.
89
+ */
90
+ var fieldCompletionContext = (text, pos) => {
91
+ const before = text.slice(0, pos);
92
+ const openFences = [...before.matchAll(new RegExp(FENCE_REGEX.source, FENCE_REGEX.flags))];
93
+ const closeFences = [...before.matchAll(/^```\s*$/gm)];
94
+ if (openFences.length === 0 || openFences.length <= closeFences.length) return;
95
+ const lastOpen = openFences[openFences.length - 1];
96
+ const fenceEnd = lastOpen.index + lastOpen[0].length;
97
+ const newlineAfterFence = text.indexOf("\n", fenceEnd);
98
+ if (newlineAfterFence === -1) return;
99
+ const firstBodyStart = newlineAfterFence + 1;
100
+ const firstBodyEnd = text.indexOf("\n", firstBodyStart);
101
+ const blockType = (firstBodyEnd === -1 ? text.slice(firstBodyStart) : text.slice(firstBodyStart, firstBodyEnd)).trim().match(/^(\w+)/)?.[1] ?? "";
102
+ const fields = BLOCK_FIELDS[blockType];
103
+ if (!fields || firstBodyEnd === -1 || pos <= firstBodyEnd) return;
104
+ return before.slice(before.lastIndexOf("\n") + 1).includes(":") ? void 0 : {
105
+ blockType,
106
+ fields
107
+ };
108
+ };
109
+ //#endregion
110
+ export { fieldCompletionContext as n, BLOCK_FIELDS as t };
111
+
112
+ //# sourceMappingURL=chunk-completion.mjs.map