@descent-vtt/spec-guard 0.10.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +410 -0
- package/README.md +385 -27
- package/dist/cites.d.ts +192 -0
- package/dist/cites.d.ts.map +1 -0
- package/dist/cites.js +599 -0
- package/dist/cites.js.map +1 -0
- package/dist/cli.d.ts +14 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +315 -22
- package/dist/cli.js.map +1 -1
- package/dist/comments.d.ts +51 -2
- package/dist/comments.d.ts.map +1 -1
- package/dist/comments.js +353 -57
- package/dist/comments.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +46 -5
- package/dist/config.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +38 -14
- package/dist/engine.js.map +1 -1
- package/dist/glob.d.ts +128 -24
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +304 -61
- package/dist/glob.js.map +1 -1
- package/dist/impact.d.ts +179 -0
- package/dist/impact.d.ts.map +1 -0
- package/dist/impact.js +360 -0
- package/dist/impact.js.map +1 -0
- package/dist/imports.d.ts.map +1 -1
- package/dist/imports.js +5 -58
- package/dist/imports.js.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +16 -75
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +198 -370
- package/dist/mcp.js.map +1 -1
- package/dist/overlay.d.ts +39 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +133 -0
- package/dist/overlay.js.map +1 -0
- package/dist/parser.d.ts +41 -24
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +217 -160
- package/dist/parser.js.map +1 -1
- package/dist/prove.d.ts +46 -0
- package/dist/prove.d.ts.map +1 -0
- package/dist/prove.js +549 -0
- package/dist/prove.js.map +1 -0
- package/dist/query.d.ts +11 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +9 -3
- package/dist/query.js.map +1 -1
- package/dist/reporter.d.ts +139 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +593 -21
- package/dist/reporter.js.map +1 -1
- package/dist/rules.js +3 -3
- package/dist/rules.js.map +1 -1
- package/dist/runner.d.ts +24 -1
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +84 -21
- package/dist/runner.js.map +1 -1
- package/dist/specs.d.ts +5 -1
- package/dist/specs.d.ts.map +1 -1
- package/dist/specs.js +5 -1
- package/dist/specs.js.map +1 -1
- package/dist/structure.d.ts.map +1 -1
- package/dist/structure.js +7 -6
- package/dist/structure.js.map +1 -1
- package/dist/types.d.ts +193 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vendor/spec-core/jsonrpc/index.d.ts +3 -0
- package/dist/vendor/spec-core/jsonrpc/index.d.ts.map +1 -0
- package/dist/vendor/spec-core/jsonrpc/index.js +2 -0
- package/dist/vendor/spec-core/jsonrpc/index.js.map +1 -0
- package/dist/vendor/spec-core/jsonrpc/mcp.d.ts +158 -0
- package/dist/vendor/spec-core/jsonrpc/mcp.d.ts.map +1 -0
- package/dist/vendor/spec-core/jsonrpc/mcp.js +353 -0
- package/dist/vendor/spec-core/jsonrpc/mcp.js.map +1 -0
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts +104 -0
- package/dist/vendor/spec-core/markdown/frontmatter.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js +459 -0
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -0
- package/dist/vendor/spec-core/markdown/headings.d.ts +46 -0
- package/dist/vendor/spec-core/markdown/headings.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/headings.js +199 -0
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -0
- package/dist/vendor/spec-core/markdown/index.d.ts +6 -0
- package/dist/vendor/spec-core/markdown/index.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/index.js +4 -0
- package/dist/vendor/spec-core/markdown/index.js.map +1 -0
- package/dist/vendor/spec-core/markdown/layout.d.ts +40 -0
- package/dist/vendor/spec-core/markdown/layout.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/layout.js +28 -0
- package/dist/vendor/spec-core/markdown/layout.js.map +1 -0
- package/dist/vendor/spec-core/markdown/links.d.ts +23 -0
- package/dist/vendor/spec-core/markdown/links.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/links.js +364 -0
- package/dist/vendor/spec-core/markdown/links.js.map +1 -0
- package/dist/vendor/spec-core/markdown/lists.d.ts +23 -0
- package/dist/vendor/spec-core/markdown/lists.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/lists.js +127 -0
- package/dist/vendor/spec-core/markdown/lists.js.map +1 -0
- package/dist/vendor/spec-core/markdown/scan.d.ts +37 -0
- package/dist/vendor/spec-core/markdown/scan.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/scan.js +439 -0
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -0
- package/dist/vendor/spec-core/markdown/syntax.d.ts +76 -0
- package/dist/vendor/spec-core/markdown/syntax.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/syntax.js +181 -0
- package/dist/vendor/spec-core/markdown/syntax.js.map +1 -0
- package/dist/vendor/spec-core/markdown/tables.d.ts +19 -0
- package/dist/vendor/spec-core/markdown/tables.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/tables.js +86 -0
- package/dist/vendor/spec-core/markdown/tables.js.map +1 -0
- package/dist/vendor/spec-core/markdown/types.d.ts +288 -0
- package/dist/vendor/spec-core/markdown/types.d.ts.map +1 -0
- package/dist/vendor/spec-core/markdown/types.js +9 -0
- package/dist/vendor/spec-core/markdown/types.js.map +1 -0
- package/dist/vendor/spec-core/path/index.d.ts +2 -0
- package/dist/vendor/spec-core/path/index.d.ts.map +1 -0
- package/dist/vendor/spec-core/path/index.js +2 -0
- package/dist/vendor/spec-core/path/index.js.map +1 -0
- package/dist/vendor/spec-core/path/posix.d.ts +84 -0
- package/dist/vendor/spec-core/path/posix.d.ts.map +1 -0
- package/dist/vendor/spec-core/path/posix.js +150 -0
- package/dist/vendor/spec-core/path/posix.js.map +1 -0
- package/dist/vendor/spec-core/pattern/automaton.d.ts +130 -0
- package/dist/vendor/spec-core/pattern/automaton.d.ts.map +1 -0
- package/dist/vendor/spec-core/pattern/automaton.js +340 -0
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -0
- package/dist/vendor/spec-core/pattern/charset.d.ts +59 -0
- package/dist/vendor/spec-core/pattern/charset.d.ts.map +1 -0
- package/dist/vendor/spec-core/pattern/charset.js +116 -0
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -0
- package/dist/vendor/spec-core/pattern/glob.d.ts +122 -0
- package/dist/vendor/spec-core/pattern/glob.d.ts.map +1 -0
- package/dist/vendor/spec-core/pattern/glob.js +481 -0
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -0
- package/dist/vendor/spec-core/pattern/index.d.ts +7 -0
- package/dist/vendor/spec-core/pattern/index.d.ts.map +1 -0
- package/dist/vendor/spec-core/pattern/index.js +4 -0
- package/dist/vendor/spec-core/pattern/index.js.map +1 -0
- package/dist/vendor/spec-core/pattern/regex.d.ts +68 -0
- package/dist/vendor/spec-core/pattern/regex.d.ts.map +1 -0
- package/dist/vendor/spec-core/pattern/regex.js +813 -0
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -0
- package/dist/vendor/spec-core/text/index.d.ts +3 -0
- package/dist/vendor/spec-core/text/index.d.ts.map +1 -0
- package/dist/vendor/spec-core/text/index.js +2 -0
- package/dist/vendor/spec-core/text/index.js.map +1 -0
- package/dist/vendor/spec-core/text/lines.d.ts +73 -0
- package/dist/vendor/spec-core/text/lines.d.ts.map +1 -0
- package/dist/vendor/spec-core/text/lines.js +156 -0
- package/dist/vendor/spec-core/text/lines.js.map +1 -0
- package/package.json +8 -1
- package/src/vendor/spec-core/LICENSE +21 -0
- package/src/vendor/spec-core/README.md +8 -0
package/dist/parser.js
CHANGED
|
@@ -8,13 +8,21 @@
|
|
|
8
8
|
* <!-- @assert-absence target="src/" symbol="LegacyPaymentGateway" -->
|
|
9
9
|
*
|
|
10
10
|
* Two properties matter more than raw speed here:
|
|
11
|
-
* 1. Directives inside
|
|
12
|
-
*
|
|
11
|
+
* 1. Directives inside code - fenced or indented blocks, code spans, and the
|
|
12
|
+
* HTML elements whose content is not Markdown - are IGNORED, so a README can
|
|
13
|
+
* document the syntax without executing it.
|
|
13
14
|
* 2. Anything that looks like a directive but is malformed is reported as an
|
|
14
15
|
* error rather than silently skipped - a typo must never turn into a
|
|
15
16
|
* silently-passing invariant.
|
|
17
|
+
*
|
|
18
|
+
* What is code, what is a comment, where the front matter ends and which lines
|
|
19
|
+
* are headings is decided by spec-core's Markdown scanner, copied into
|
|
20
|
+
* `src/vendor` and verified by hash, which every spec-* tool reads documents
|
|
21
|
+
* with. This module keeps what is spec-guard's: the directive grammar, and
|
|
22
|
+
* what a status line means. ADR-0002.
|
|
16
23
|
*/
|
|
17
|
-
import { lineStarts, locate
|
|
24
|
+
import { lineStarts, locate } from './text.js';
|
|
25
|
+
import { findEntry, readFrontMatter, scanMarkdown, titleOf } from './vendor/spec-core/markdown/index.js';
|
|
18
26
|
/** Every directive spec-guard understands. */
|
|
19
27
|
export const KINDS = new Set([
|
|
20
28
|
'assert-absence',
|
|
@@ -129,12 +137,14 @@ export const ALLOWED_ATTRIBUTES = {
|
|
|
129
137
|
* Status words that withhold a document's directives from execution.
|
|
130
138
|
*
|
|
131
139
|
* The words that mean "not in force" in Nygard's ADR template and in MADR's
|
|
132
|
-
* between them, plus `draft`, which is the one people actually type
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
140
|
+
* between them, plus `draft`, which is the one people actually type, and
|
|
141
|
+
* `archived`, which `spec-brief` writes when it closes a task brief's round -
|
|
142
|
+
* whose directives stated premises and goals that are history once it closes.
|
|
143
|
+
* The list is closed and short on purpose: every word added to it is another
|
|
144
|
+
* way for a document to go dark, and a rule that stops being enforced without
|
|
145
|
+
* anyone deciding so is the failure this tool exists to prevent. Anything else -
|
|
146
|
+
* an unrecognised word, a misspelling, no status at all - stays in force. See
|
|
147
|
+
* ADR-0010 and its amendment.
|
|
138
148
|
*/
|
|
139
149
|
export const INACTIVE_STATUSES = new Set([
|
|
140
150
|
'draft',
|
|
@@ -142,9 +152,8 @@ export const INACTIVE_STATUSES = new Set([
|
|
|
142
152
|
'rejected',
|
|
143
153
|
'deprecated',
|
|
144
154
|
'superseded',
|
|
155
|
+
'archived',
|
|
145
156
|
]);
|
|
146
|
-
/** `---\n...\n---` at the very top of the file, and nowhere else. */
|
|
147
|
-
const FRONTMATTER_RE = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
148
157
|
/**
|
|
149
158
|
* The three ways the key is spelled: `**Status**:`, `**Status:**`, `Status:`.
|
|
150
159
|
*
|
|
@@ -158,26 +167,6 @@ const FRONTMATTER_RE = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
|
158
167
|
* which trims it anyway.
|
|
159
168
|
*/
|
|
160
169
|
const STATUS_LABEL_RE = /^[ \t]{0,3}(?:(\*\*|__)status(?:\1[ \t]*:|[ \t]*:\1)|status[ \t]*:)(.*)/i;
|
|
161
|
-
/**
|
|
162
|
-
* The value a YAML scalar holds: a quoted one up to its closing quote, a plain
|
|
163
|
-
* one up to a comment.
|
|
164
|
-
*
|
|
165
|
-
* Not a YAML parser, and it does not need to be one - it reads one line. But
|
|
166
|
-
* it has to read that line the way YAML does. MADR's own template quotes the
|
|
167
|
-
* status, and a quote left in leaves no first word to read; a trailing
|
|
168
|
-
* `# decided at review` left in is part of the label; and a regex anchored at
|
|
169
|
-
* both ends of a quoted value read `"proposed" # a comment` as no status at
|
|
170
|
-
* all, which keeps a withdrawn proposal in force.
|
|
171
|
-
*/
|
|
172
|
-
function yamlScalar(raw) {
|
|
173
|
-
const text = raw.trim();
|
|
174
|
-
const quoted = /^(["'])(.*?)\1/.exec(text);
|
|
175
|
-
return quoted ? quoted[2] : text.replace(/\s#.*/, '');
|
|
176
|
-
}
|
|
177
|
-
/** An ATX heading whose entire text is "Status". */
|
|
178
|
-
const STATUS_HEADING_RE = /^[ \t]{0,3}#{1,6}[ \t]+status[ \t]*#*[ \t]*$/i;
|
|
179
|
-
/** Any ATX heading of level 2 or deeper - where a document's preamble ends. */
|
|
180
|
-
const SECTION_HEADING_RE = /^[ \t]{0,3}#{2,6}[ \t]/;
|
|
181
170
|
/**
|
|
182
171
|
* Turns a status line into a status, or into nothing.
|
|
183
172
|
*
|
|
@@ -203,63 +192,87 @@ function toStatus(raw, source) {
|
|
|
203
192
|
return { value, label, source, active: !INACTIVE_STATUSES.has(value) };
|
|
204
193
|
}
|
|
205
194
|
/**
|
|
206
|
-
*
|
|
195
|
+
* The status front matter declares, read as YAML reads it, or undefined when
|
|
196
|
+
* front matter names none.
|
|
197
|
+
*
|
|
198
|
+
* spec-core's reader, which the family's tools share: a quoted value is taken
|
|
199
|
+
* up to its closing quote and a plain one up to a comment, as the one-line
|
|
200
|
+
* reader this replaced did - MADR's own template quotes the status, and
|
|
201
|
+
* `"proposed" # decided at review` is proposed. Quotes and `#` are syntax here
|
|
202
|
+
* and nowhere else.
|
|
207
203
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
204
|
+
* A `status` key decides, whether or not its value can be read. One the reader
|
|
205
|
+
* refuses - continued onto the next line, text after a closing quote, `: ` in
|
|
206
|
+
* a plain value - or one with no word in it declares no status, which leaves
|
|
207
|
+
* the document in force, and says why. It used to be skipped, and then a
|
|
208
|
+
* `## Status` section or a `Status:` line further down was read in its place:
|
|
209
|
+
* `status: "accepted" (2024-05-01)` above a section still saying `Proposed`
|
|
210
|
+
* took an accepted decision out of force.
|
|
213
211
|
*/
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
function fromFrontmatter(masked) {
|
|
218
|
-
const block = FRONTMATTER_RE.exec(masked);
|
|
219
|
-
if (!block)
|
|
212
|
+
function fromFrontmatter(scan) {
|
|
213
|
+
if (scan.frontMatter === null)
|
|
220
214
|
return undefined;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
215
|
+
const entry = findEntry(readFrontMatter(scan.text.slice(0, scan.frontMatter.bodyStart)), 'status');
|
|
216
|
+
if (entry === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
const { value } = entry;
|
|
219
|
+
const status = value.kind === 'scalar' ? toStatus(value.scalar.text, 'frontmatter') : undefined;
|
|
220
|
+
if (status !== undefined)
|
|
221
|
+
return { status };
|
|
222
|
+
const reason = value.kind === 'unsupported'
|
|
223
|
+
? value.reason
|
|
224
|
+
: value.kind === 'list'
|
|
225
|
+
? 'a list is not a status'
|
|
226
|
+
: value.scalar.text.trim() === ''
|
|
227
|
+
? 'it is empty'
|
|
228
|
+
: `"${value.scalar.text}" does not begin with a word`;
|
|
229
|
+
return {
|
|
230
|
+
problem: {
|
|
231
|
+
// The reader counts lines from 0 in the text the scan read, which is the
|
|
232
|
+
// document's own lines after any byte-order mark.
|
|
233
|
+
line: entry.line + 1,
|
|
234
|
+
message: `the status in front matter cannot be read (${reason}), so its status is unrecognised and the document stays in force; a status written below the front matter is not read in its place`,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
229
237
|
}
|
|
230
238
|
/**
|
|
231
239
|
* A `## Status` section, whose value is the first line of prose under it.
|
|
232
240
|
*
|
|
241
|
+
* The section is a heading the scanner reads - ATX or setext, at any level, and
|
|
242
|
+
* never one inside code or a comment, which is where a template keeps a
|
|
243
|
+
* `## Status` it has not filled in. Its text is compared whole, so `## Status
|
|
244
|
+
* of the migration` is a section about something else.
|
|
245
|
+
*
|
|
233
246
|
* A section with nothing but the next heading under it declares no status.
|
|
234
|
-
* There is no guard for that here:
|
|
235
|
-
*
|
|
236
|
-
* guard this used to carry could not decide anything, which is a different
|
|
237
|
-
* thing from a guard that is merely never hit.
|
|
247
|
+
* There is no guard for that here: an ATX heading begins with `#`, and a value
|
|
248
|
+
* that does not begin with a letter is already no status at all.
|
|
238
249
|
*/
|
|
239
|
-
function fromHeading(
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
250
|
+
function fromHeading(scan) {
|
|
251
|
+
const heading = scan.headings.find((candidate) => candidate.text.toLowerCase() === 'status');
|
|
252
|
+
if (heading === undefined)
|
|
242
253
|
return undefined;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
254
|
+
const view = scan.masks.directives;
|
|
255
|
+
for (const line of scan.lines.slice(heading.endLine)) {
|
|
256
|
+
const candidate = view.slice(line.start, line.end).trim();
|
|
257
|
+
if (candidate.length > 0)
|
|
258
|
+
return toStatus(candidate, 'heading');
|
|
248
259
|
}
|
|
249
260
|
return undefined;
|
|
250
261
|
}
|
|
251
262
|
/**
|
|
252
263
|
* A `**Status:** accepted` line in the document's preamble.
|
|
253
264
|
*
|
|
254
|
-
* Bounded to the preamble - everything before the first
|
|
255
|
-
* form is a line of prose with a colon in it, and a
|
|
256
|
-
* anywhere in a long document will eventually find one in
|
|
265
|
+
* Bounded to the preamble - everything before the first heading of level two
|
|
266
|
+
* or deeper - because this form is a line of prose with a colon in it, and a
|
|
267
|
+
* tool that accepts one anywhere in a long document will eventually find one in
|
|
268
|
+
* a sentence. The bound is a heading the scanner reads, so a `##` shown in code
|
|
269
|
+
* or kept in a comment does not end the preamble early.
|
|
257
270
|
*/
|
|
258
|
-
function fromLabel(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const found = STATUS_LABEL_RE.exec(line);
|
|
271
|
+
function fromLabel(scan) {
|
|
272
|
+
const section = scan.headings.find((heading) => heading.level >= 2);
|
|
273
|
+
const view = scan.masks.directives;
|
|
274
|
+
for (const line of section === undefined ? scan.lines : scan.lines.slice(0, section.line - 1)) {
|
|
275
|
+
const found = STATUS_LABEL_RE.exec(view.slice(line.start, line.end));
|
|
263
276
|
if (found)
|
|
264
277
|
return toStatus(found[2], 'label');
|
|
265
278
|
}
|
|
@@ -270,105 +283,96 @@ function fromLabel(lines) {
|
|
|
270
283
|
*
|
|
271
284
|
* Three spellings are recognised because three are in use, including two in
|
|
272
285
|
* this repository's own ADRs: YAML front-matter (MADR), a `## Status` section
|
|
273
|
-
* (Nygard), and a bold `**Status:**` label. Front-matter wins when
|
|
274
|
-
* it is machine-readable metadata rather than
|
|
286
|
+
* (Nygard), and a bold `**Status:**` label. Front-matter wins when it has a
|
|
287
|
+
* `status` key, readable or not - it is machine-readable metadata rather than
|
|
288
|
+
* a convention read out of prose, and a value it cannot read is no licence to
|
|
289
|
+
* read the prose instead.
|
|
275
290
|
*
|
|
276
|
-
*
|
|
277
|
-
* fence - this project's README does - is not
|
|
291
|
+
* The section and the label are read with code masked, so a document that
|
|
292
|
+
* documents this syntax inside a fence - this project's README does - is not
|
|
293
|
+
* read as declaring a status.
|
|
278
294
|
*/
|
|
279
295
|
export function parseStatus(source) {
|
|
280
|
-
return statusOf(
|
|
296
|
+
return statusOf(scanMarkdown(source)).status;
|
|
281
297
|
}
|
|
282
|
-
function statusOf(
|
|
283
|
-
|
|
284
|
-
return fromFrontmatter(masked) ?? fromHeading(lines) ?? fromLabel(lines);
|
|
298
|
+
function statusOf(scan) {
|
|
299
|
+
return fromFrontmatter(scan) ?? { status: fromHeading(scan) ?? fromLabel(scan) };
|
|
285
300
|
}
|
|
286
|
-
/** An ATX heading of level 1, with any closing sequence taken off. */
|
|
287
|
-
const TITLE_RE = /^[ \t]{0,3}#[ \t]+(.*?)(?:[ \t]+#+)?[ \t]*$/;
|
|
288
301
|
/**
|
|
289
|
-
* The document's title: its first level-one heading
|
|
302
|
+
* The document's title: its first level-one heading, ATX or setext, as the
|
|
303
|
+
* scanner reads it.
|
|
290
304
|
*
|
|
291
305
|
* Read so that a rule can be shown with the decision it belongs to - "ADR-0011:
|
|
292
306
|
* Layering constraints and import cycles" says more to someone about to edit a
|
|
293
|
-
* file than `docs/adr/0011-layers-and-cycles.md` does. Front
|
|
294
|
-
*
|
|
295
|
-
* an example ADR inside a fence
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* ADR that way, and a reader that guessed at underlines would find titles in
|
|
299
|
-
* tables.
|
|
307
|
+
* file than `docs/adr/0011-layers-and-cycles.md` does. Front matter, code and
|
|
308
|
+
* comments are not read, for the same reasons as the status: a README that
|
|
309
|
+
* shows an example ADR inside a fence, or a template that keeps its heading in
|
|
310
|
+
* a comment, has not titled itself with it. A first level-one heading with no
|
|
311
|
+
* text is no title.
|
|
300
312
|
*/
|
|
301
313
|
export function parseTitle(source) {
|
|
302
|
-
return
|
|
314
|
+
return titleIn(scanMarkdown(source));
|
|
303
315
|
}
|
|
304
|
-
function
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
316
|
+
function titleIn(scan) {
|
|
317
|
+
const title = titleOf(scan)?.text;
|
|
318
|
+
return title === '' ? undefined : title;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* A code fence or raw-text HTML block that is never closed and runs to the end
|
|
322
|
+
* of the document, with something in it after its opening line.
|
|
323
|
+
*
|
|
324
|
+
* CommonMark reads one so, and so does the scanner: every line after it is
|
|
325
|
+
* code, and a directive there does not run. That is a document whose rules
|
|
326
|
+
* stop at a typo, and nothing else says so - a run over it is as green as one
|
|
327
|
+
* over a document that states no more rules. One closed by the end of its
|
|
328
|
+
* block quote hides nothing past the quote, and one on the last line hides
|
|
329
|
+
* nothing at all.
|
|
330
|
+
*/
|
|
331
|
+
function unclosedBlocks(scan) {
|
|
332
|
+
const found = [];
|
|
333
|
+
for (const block of scan.blocks) {
|
|
334
|
+
// An indented block is always closed: it ends where the indentation does.
|
|
335
|
+
if (block.closed || scan.text.slice(block.end).trim() !== '')
|
|
336
|
+
continue;
|
|
337
|
+
if (scan.lines.slice(block.line, block.endLine).every((line) => line.blank))
|
|
338
|
+
continue;
|
|
339
|
+
const opener = scan.lines[block.line - 1].content.trim();
|
|
340
|
+
// A raw-text block's first line starts with its tag, or it would be none.
|
|
341
|
+
const what = block.kind === 'fenced'
|
|
342
|
+
? `the code fence ${opener} opened here is never closed`
|
|
343
|
+
: `the ${/^<[a-z]+/i.exec(opener)[0].toLowerCase()}> block opened here is never closed`;
|
|
344
|
+
found.push({
|
|
345
|
+
line: block.line,
|
|
346
|
+
message: `${what}, so lines ${block.line} to ${block.endLine}, the rest of the document, are read as code, and no directive in them runs`,
|
|
347
|
+
});
|
|
310
348
|
}
|
|
311
|
-
return
|
|
349
|
+
return found;
|
|
312
350
|
}
|
|
313
351
|
const DIRECTIVE_RE = /<!--\s*@([a-zA-Z][\w-]*)([\s\S]*?)-->/g;
|
|
352
|
+
/** The opening of a directive, `<!-- @kind`, wherever it is written. */
|
|
353
|
+
const DIRECTIVE_SHAPE_RE = /<!--\s*@([a-zA-Z][\w-]*)/g;
|
|
314
354
|
const ATTRIBUTE_RE = /([a-zA-Z][\w-]*)(?:\s*=\s*(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|([^\s"'=<>`]+)))?/g;
|
|
315
355
|
/**
|
|
316
|
-
*
|
|
317
|
-
*
|
|
356
|
+
* The source with its code blanked and its comments kept, offset for offset:
|
|
357
|
+
* the scanner's directives mask, behind the byte-order mark it took off. A
|
|
358
|
+
* match at an offset of this is at that offset of the source, so a directive
|
|
359
|
+
* is reported on the line and in the column a person finds it.
|
|
360
|
+
*/
|
|
361
|
+
function directivesView(source, scan) {
|
|
362
|
+
return source.slice(0, scan.bom) + scan.masks.directives;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Blanks out what is not read for directives - fenced and indented code, code
|
|
366
|
+
* spans, `<script>`, `<pre>`, `<style>` and `<textarea>` blocks, and front
|
|
367
|
+
* matter - preserving every offset and line terminator, so that reported
|
|
368
|
+
* line/column numbers stay exact. Comments are kept: a directive is one.
|
|
369
|
+
*
|
|
370
|
+
* spec-core's scanner decides all of it, in one pass, by CommonMark's rules for
|
|
371
|
+
* what is code and what is a comment: whichever of a code span and a comment
|
|
372
|
+
* opens first wins, and a code span ends with its paragraph. ADR-0002.
|
|
318
373
|
*/
|
|
319
374
|
export function maskCode(source) {
|
|
320
|
-
|
|
321
|
-
// place. The array was `source.split('')` - one string per UTF-16 unit - and
|
|
322
|
-
// measured at 7.2ms over this repository's 183KB of specs against 0.8ms for
|
|
323
|
-
// the ranges, with identical output on every one of them and on 50,000
|
|
324
|
-
// random inputs. It became worth measuring when `spec-guard query` put a
|
|
325
|
-
// budget on reading specs; see ADR-0012. Offsets still survive, for the reason
|
|
326
|
-
// `maskRanges` gives.
|
|
327
|
-
// Fenced code blocks: ``` or ~~~ (3+ markers), optionally indented up to 3 spaces.
|
|
328
|
-
const fenceRe = /^[ \t]{0,3}(`{3,}|~{3,})[^\n]*$/gm;
|
|
329
|
-
let match;
|
|
330
|
-
const fences = [];
|
|
331
|
-
while ((match = fenceRe.exec(source)) !== null) {
|
|
332
|
-
fences.push({ index: match.index, end: match.index + match[0].length, marker: match[1] });
|
|
333
|
-
}
|
|
334
|
-
const consumed = [];
|
|
335
|
-
for (let i = 0; i < fences.length; i++) {
|
|
336
|
-
const open = fences[i];
|
|
337
|
-
if (consumed.some(([s, e]) => open.index >= s && open.index < e))
|
|
338
|
-
continue;
|
|
339
|
-
const char = open.marker[0];
|
|
340
|
-
let closeEnd = source.length;
|
|
341
|
-
for (let j = i + 1; j < fences.length; j++) {
|
|
342
|
-
const candidate = fences[j];
|
|
343
|
-
if (candidate.marker[0] === char && candidate.marker.length >= open.marker.length) {
|
|
344
|
-
closeEnd = candidate.end;
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
consumed.push([open.index, closeEnd]);
|
|
349
|
-
}
|
|
350
|
-
// Inline code spans, using CommonMark's rule: a run of N backticks is closed
|
|
351
|
-
// by the next run of EXACTLY N backticks. Runs of a different length are
|
|
352
|
-
// skipped rather than treated as a closer - otherwise a stray ``` inside a
|
|
353
|
-
// sentence shifts every later pairing by one and un-masks real prose.
|
|
354
|
-
const masked = maskRanges(source, consumed);
|
|
355
|
-
const spans = [];
|
|
356
|
-
const runs = [];
|
|
357
|
-
const runRe = /`+/g;
|
|
358
|
-
let run;
|
|
359
|
-
while ((run = runRe.exec(masked)) !== null) {
|
|
360
|
-
runs.push({ index: run.index, length: run[0].length });
|
|
361
|
-
}
|
|
362
|
-
for (let index = 0; index < runs.length; index++) {
|
|
363
|
-
const open = runs[index];
|
|
364
|
-
const closeIndex = runs.findIndex((candidate, position) => position > index && candidate.length === open.length);
|
|
365
|
-
if (closeIndex === -1)
|
|
366
|
-
continue;
|
|
367
|
-
const close = runs[closeIndex];
|
|
368
|
-
spans.push([open.index, close.index + close.length]);
|
|
369
|
-
index = closeIndex;
|
|
370
|
-
}
|
|
371
|
-
return maskRanges(masked, spans);
|
|
375
|
+
return directivesView(source, scanMarkdown(source));
|
|
372
376
|
}
|
|
373
377
|
/**
|
|
374
378
|
* Undoes the escapes a quoted value needs: `\"`, `\'` and `\\`.
|
|
@@ -395,24 +399,29 @@ export function parseAttributes(input) {
|
|
|
395
399
|
}
|
|
396
400
|
/** Extracts every spec-guard directive from a Markdown source string. */
|
|
397
401
|
export function parseDirectives(source, context) {
|
|
398
|
-
return directivesOf(source,
|
|
402
|
+
return directivesOf(source, scanMarkdown(source), context);
|
|
399
403
|
}
|
|
400
404
|
/**
|
|
401
|
-
* Everything a spec document declares, read with one
|
|
405
|
+
* Everything a spec document declares, read with one scan.
|
|
402
406
|
*
|
|
403
|
-
* `parseDirectives` and `parseTitle` each
|
|
407
|
+
* `parseDirectives` and `parseTitle` each scan the source, and scanning is most
|
|
404
408
|
* of what reading a spec costs; a caller that wants both should not pay twice.
|
|
405
409
|
*/
|
|
406
410
|
export function parseDocument(source, context) {
|
|
407
|
-
const
|
|
408
|
-
const parsed = directivesOf(source,
|
|
409
|
-
const title =
|
|
411
|
+
const scan = scanMarkdown(source);
|
|
412
|
+
const parsed = directivesOf(source, scan, context);
|
|
413
|
+
const title = titleIn(scan);
|
|
410
414
|
return title === undefined ? parsed : { ...parsed, title };
|
|
411
415
|
}
|
|
412
|
-
function directivesOf(source,
|
|
416
|
+
function directivesOf(source, scan, context) {
|
|
413
417
|
const directives = [];
|
|
414
418
|
const errors = [];
|
|
419
|
+
// Lines as they have always been counted here, by `\n`, so a directive is
|
|
420
|
+
// reported where it was. The scanner counts a lone `\r` as well, and reads
|
|
421
|
+
// the document by it, but a line number in a report is not the place to
|
|
422
|
+
// change what a line is.
|
|
415
423
|
const starts = lineStarts(source);
|
|
424
|
+
const masked = directivesView(source, scan);
|
|
416
425
|
DIRECTIVE_RE.lastIndex = 0;
|
|
417
426
|
let match;
|
|
418
427
|
while ((match = DIRECTIVE_RE.exec(masked)) !== null) {
|
|
@@ -452,7 +461,55 @@ function directivesOf(source, masked, context) {
|
|
|
452
461
|
}
|
|
453
462
|
directives.push({ kind: kind, attributes, location, raw });
|
|
454
463
|
}
|
|
455
|
-
const status = statusOf(
|
|
456
|
-
|
|
464
|
+
const { status, problem } = statusOf(scan);
|
|
465
|
+
const at = (line) => ({ file: context.file, relativeFile: context.relativeFile, line, column: 1 });
|
|
466
|
+
const warnings = [
|
|
467
|
+
...(problem === undefined ? [] : [{ location: at(problem.line), kind: 'unreadable-status', message: problem.message }]),
|
|
468
|
+
...unclosedBlocks(scan).map(({ line, message }) => ({ location: at(line), kind: 'unclosed-block', message })),
|
|
469
|
+
];
|
|
470
|
+
const hidden = maskedDirectives(source, masked, scan, starts, context);
|
|
471
|
+
return {
|
|
472
|
+
directives,
|
|
473
|
+
errors,
|
|
474
|
+
...(status === undefined ? {} : { status }),
|
|
475
|
+
...(warnings.length === 0 ? {} : { warnings }),
|
|
476
|
+
...(hidden.length === 0 ? {} : { masked: hidden }),
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Every directive-shaped comment the masked copy blanked: `<!--`, an `@`, and
|
|
481
|
+
* a kind that begins with `assert`, as the parser's own test of what "clearly
|
|
482
|
+
* meant to be a directive" is.
|
|
483
|
+
*
|
|
484
|
+
* Found in the source as written, where the parser reads the masked copy, and
|
|
485
|
+
* kept when its `<!--` is blanked there. A kind is read in any case, as the
|
|
486
|
+
* parser reads one.
|
|
487
|
+
*
|
|
488
|
+
* One search finds them all, and a document with no `<!-- @` in it costs no
|
|
489
|
+
* more than that. A search for `@assert` used to come first, to spare the
|
|
490
|
+
* documents without one; it could decide nothing this one does not, and it
|
|
491
|
+
* saved nothing measurable (ADR-0002).
|
|
492
|
+
*/
|
|
493
|
+
function maskedDirectives(source, view, scan, starts, context) {
|
|
494
|
+
const found = [];
|
|
495
|
+
for (const match of source.matchAll(DIRECTIVE_SHAPE_RE)) {
|
|
496
|
+
if (view.startsWith('<!--', match.index) || !match[1].toLowerCase().startsWith('assert'))
|
|
497
|
+
continue;
|
|
498
|
+
const { line, column } = locate(starts, match.index);
|
|
499
|
+
found.push({ location: { file: context.file, relativeFile: context.relativeFile, line, column }, inside: maskedBy(scan, match.index - scan.bom) });
|
|
500
|
+
}
|
|
501
|
+
return found;
|
|
502
|
+
}
|
|
503
|
+
const BLOCKS = { fenced: 'fenced code', indented: 'indented code', html: 'raw HTML' };
|
|
504
|
+
/**
|
|
505
|
+
* What blanked an offset of the scanned text: the front matter, a block, or
|
|
506
|
+
* else a code span, the one construct left. The body starts at 0 in a document
|
|
507
|
+
* with no front matter, so nothing is before it.
|
|
508
|
+
*/
|
|
509
|
+
function maskedBy(scan, offset) {
|
|
510
|
+
if (offset < scan.bodyStart)
|
|
511
|
+
return 'front matter';
|
|
512
|
+
const block = scan.blocks.find((candidate) => candidate.start <= offset && offset < candidate.end);
|
|
513
|
+
return block === undefined ? 'code span' : BLOCKS[block.kind];
|
|
457
514
|
}
|
|
458
515
|
//# sourceMappingURL=parser.js.map
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAU3D,8CAA8C;AAC9C,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS;IACnC,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;IACrB,qBAAqB;IACrB,eAAe;IACf,kBAAkB;CACnB,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA+C;IAC5E,gBAAgB,EAAE,IAAI,GAAG,CAAC;QACxB,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,KAAK;QACL,MAAM;QACN,SAAS;QACT,UAAU;QACV,OAAO;QACP,MAAM;QACN,aAAa;QACb,aAAa;QACb,UAAU;QACV,SAAS;QACT,QAAQ;KACT,CAAC;IACF,cAAc,EAAE,IAAI,GAAG,CAAC;QACtB,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,KAAK;QACL,KAAK;QACL,MAAM;QACN,SAAS;QACT,UAAU;QACV,OAAO;QACP,MAAM;QACN,aAAa;QACb,aAAa;QACb,QAAQ;KACT,CAAC;IACF,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,uBAAuB,EAAE,IAAI,GAAG,CAAC;QAC/B,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,OAAO;QACP,UAAU;QACV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AAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/prove.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `spec-guard prove`: can each rule actually fail? ADR-0016.
|
|
3
|
+
*
|
|
4
|
+
* A rule that cannot fail is a green light that proves nothing. A directory
|
|
5
|
+
* renamed under a target, a `glob` that misses the extension the code is
|
|
6
|
+
* written in, a module name nothing imports by that name: each leaves a rule
|
|
7
|
+
* that passes today and would pass whatever the code did. A run cannot tell
|
|
8
|
+
* that rule from one that holds, because both pass.
|
|
9
|
+
*
|
|
10
|
+
* So each rule in force is shown a violation of itself and has to fail. The
|
|
11
|
+
* violation is made in memory - a file added, a line put at the top of one, a
|
|
12
|
+
* file emptied or removed - through an overlay on the door every read goes
|
|
13
|
+
* through, and the rule is executed over that tree exactly as a run executes
|
|
14
|
+
* it. Nothing is written to disk and nothing touches git. A rule the violation
|
|
15
|
+
* fails is `killed`; one that still passes `survived`, and the violation is
|
|
16
|
+
* reported, because that is the finding; one no violation could be made for is
|
|
17
|
+
* `unprovable`, with the reason.
|
|
18
|
+
*/
|
|
19
|
+
import { type RunOptions } from './runner.js';
|
|
20
|
+
import type { ProveReport } from './types.js';
|
|
21
|
+
export type ProveOptions = Pick<RunOptions, 'patterns' | 'root' | 'allowMissingTargets' | 'strictTargets' | 'allowEmptyScope' | 'includeSpecs' | 'defaultSkips' | 'exclude' | 'ignoreStatus' | 'io'>;
|
|
22
|
+
/** The name every file `prove` adds starts with, so a reader can tell which ones it made. */
|
|
23
|
+
export declare const PROVE_NAME = "spec-guard-prove";
|
|
24
|
+
/**
|
|
25
|
+
* Text a regular expression matches, or null.
|
|
26
|
+
*
|
|
27
|
+
* Built for what a rule is written with - literals, escapes, classes, groups,
|
|
28
|
+
* alternatives, counted repetition - and held to the rule's own matcher before
|
|
29
|
+
* it is used, so a wrong guess is never reported as a violation: it makes the
|
|
30
|
+
* rule `unprovable`, with the reason. Lookaround and backreferences are not
|
|
31
|
+
* guessed at.
|
|
32
|
+
*/
|
|
33
|
+
export declare function regexWitness(source: string): string | null;
|
|
34
|
+
/** A line that depends on `module`, in the language of a file with this extension. */
|
|
35
|
+
export declare function importLine(extension: string, module: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Shows each rule in force a violation of itself, in memory, and reports which
|
|
38
|
+
* ones failed.
|
|
39
|
+
*
|
|
40
|
+
* Reads through `options.io` as a run does, and through the filesystem when it
|
|
41
|
+
* is given none, and writes nothing. Rules are proved one at a time, each over
|
|
42
|
+
* its own tree, in the order the specs state them, so the report is the same
|
|
43
|
+
* every time the tree is.
|
|
44
|
+
*/
|
|
45
|
+
export declare function proveSpecGuard(options: ProveOptions): Promise<ProveReport>;
|
|
46
|
+
//# sourceMappingURL=prove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAYH,OAAO,EAA8E,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAG1H,OAAO,KAAK,EAKV,WAAW,EAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,UAAU,EACR,UAAU,GACV,MAAM,GACN,qBAAqB,GACrB,eAAe,GACf,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,SAAS,GACT,cAAc,GACd,IAAI,CACP,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,UAAU,qBAAqB,CAAC;AAsI7C;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2D1D;AA8DD,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAwPD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA+BhF"}
|