@driftsys/markspec 0.11.0 → 0.12.1

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 (176) hide show
  1. package/README.md +9 -0
  2. package/esm/ast/normalize.d.ts +4 -5
  3. package/esm/ast/normalize.d.ts.map +1 -1
  4. package/esm/ast/normalize.js +6 -37
  5. package/esm/collect/mod.d.ts +29 -9
  6. package/esm/collect/mod.d.ts.map +1 -1
  7. package/esm/collect/mod.js +36 -10
  8. package/esm/compiler/mod.d.ts.map +1 -1
  9. package/esm/compiler/mod.js +2 -6
  10. package/esm/config/markspec.d.ts +5 -3
  11. package/esm/config/markspec.d.ts.map +1 -1
  12. package/esm/config/mod.d.ts.map +1 -1
  13. package/esm/config/mod.js +47 -5
  14. package/esm/discovery/mod.d.ts +24 -8
  15. package/esm/discovery/mod.d.ts.map +1 -1
  16. package/esm/discovery/mod.js +57 -21
  17. package/esm/discovery/projects.d.ts +111 -0
  18. package/esm/discovery/projects.d.ts.map +1 -0
  19. package/esm/discovery/projects.js +242 -0
  20. package/esm/formatter/entry_body.d.ts +84 -0
  21. package/esm/formatter/entry_body.d.ts.map +1 -0
  22. package/esm/formatter/entry_body.js +291 -0
  23. package/esm/formatter/md_equiv.d.ts +6 -5
  24. package/esm/formatter/md_equiv.d.ts.map +1 -1
  25. package/esm/formatter/md_equiv.js +6 -5
  26. package/esm/formatter/mod.d.ts +16 -9
  27. package/esm/formatter/mod.d.ts.map +1 -1
  28. package/esm/formatter/mod.js +327 -53
  29. package/esm/formatter/tab_markers.d.ts +15 -0
  30. package/esm/formatter/tab_markers.d.ts.map +1 -0
  31. package/esm/formatter/tab_markers.js +133 -0
  32. package/esm/gates/mod.d.ts.map +1 -1
  33. package/esm/gates/mod.js +6 -5
  34. package/esm/lint/runner.d.ts.map +1 -1
  35. package/esm/lint/runner.js +4 -4
  36. package/esm/lock/check.d.ts.map +1 -1
  37. package/esm/lock/check.js +2 -1
  38. package/esm/lock/edge_drift.d.ts +2 -0
  39. package/esm/lock/edge_drift.d.ts.map +1 -1
  40. package/esm/lock/edge_drift.js +4 -0
  41. package/esm/lock/mod.d.ts +1 -1
  42. package/esm/lock/mod.d.ts.map +1 -1
  43. package/esm/lock/mod.js +1 -1
  44. package/esm/lock/upstream_deps.js +1 -1
  45. package/esm/mod.d.ts +11 -6
  46. package/esm/mod.d.ts.map +1 -1
  47. package/esm/mod.js +9 -6
  48. package/esm/model/mod.d.ts +22 -1
  49. package/esm/model/mod.d.ts.map +1 -1
  50. package/esm/model/mod.js +10 -0
  51. package/esm/parser/code_regions.d.ts +29 -0
  52. package/esm/parser/code_regions.d.ts.map +1 -0
  53. package/esm/parser/code_regions.js +38 -0
  54. package/esm/parser/markdown.d.ts.map +1 -1
  55. package/esm/parser/markdown.js +103 -40
  56. package/esm/parser/mod.d.ts.map +1 -1
  57. package/esm/parser/mod.js +7 -1
  58. package/esm/parser/translate.d.ts.map +1 -1
  59. package/esm/parser/translate.js +5 -0
  60. package/esm/refs/mod.d.ts +6 -2
  61. package/esm/refs/mod.d.ts.map +1 -1
  62. package/esm/refs/mod.js +15 -21
  63. package/esm/reporter/mod.d.ts.map +1 -1
  64. package/esm/reporter/mod.js +2 -2
  65. package/esm/sync/mapping.d.ts +4 -3
  66. package/esm/sync/mapping.d.ts.map +1 -1
  67. package/esm/sync/mapping.js +52 -9
  68. package/esm/util/display_id.d.ts +20 -0
  69. package/esm/util/display_id.d.ts.map +1 -0
  70. package/esm/util/display_id.js +19 -0
  71. package/esm/util/fence.d.ts +20 -29
  72. package/esm/util/fence.d.ts.map +1 -1
  73. package/esm/util/fence.js +42 -50
  74. package/esm/util/modals.d.ts +6 -0
  75. package/esm/util/modals.d.ts.map +1 -1
  76. package/esm/util/modals.js +37 -0
  77. package/esm/validator/body_blocks.d.ts +2 -1
  78. package/esm/validator/body_blocks.d.ts.map +1 -1
  79. package/esm/validator/body_blocks.js +80 -2
  80. package/esm/validator/corpus.d.ts +6 -0
  81. package/esm/validator/corpus.d.ts.map +1 -1
  82. package/esm/validator/corpus.js +16 -4
  83. package/esm/validator/mod.d.ts +1 -1
  84. package/esm/validator/mod.d.ts.map +1 -1
  85. package/esm/validator/mod.js +1 -1
  86. package/esm/validator/pipeline.d.ts +6 -4
  87. package/esm/validator/pipeline.d.ts.map +1 -1
  88. package/esm/validator/pipeline.js +24 -19
  89. package/package.json +1 -1
  90. package/script/ast/normalize.d.ts +4 -5
  91. package/script/ast/normalize.d.ts.map +1 -1
  92. package/script/ast/normalize.js +5 -36
  93. package/script/collect/mod.d.ts +29 -9
  94. package/script/collect/mod.d.ts.map +1 -1
  95. package/script/collect/mod.js +38 -10
  96. package/script/compiler/mod.d.ts.map +1 -1
  97. package/script/compiler/mod.js +1 -5
  98. package/script/config/markspec.d.ts +5 -3
  99. package/script/config/markspec.d.ts.map +1 -1
  100. package/script/config/mod.d.ts.map +1 -1
  101. package/script/config/mod.js +47 -5
  102. package/script/discovery/mod.d.ts +24 -8
  103. package/script/discovery/mod.d.ts.map +1 -1
  104. package/script/discovery/mod.js +56 -20
  105. package/script/discovery/projects.d.ts +111 -0
  106. package/script/discovery/projects.d.ts.map +1 -0
  107. package/script/discovery/projects.js +250 -0
  108. package/script/formatter/entry_body.d.ts +84 -0
  109. package/script/formatter/entry_body.d.ts.map +1 -0
  110. package/script/formatter/entry_body.js +296 -0
  111. package/script/formatter/md_equiv.d.ts +6 -5
  112. package/script/formatter/md_equiv.d.ts.map +1 -1
  113. package/script/formatter/md_equiv.js +6 -5
  114. package/script/formatter/mod.d.ts +16 -9
  115. package/script/formatter/mod.d.ts.map +1 -1
  116. package/script/formatter/mod.js +324 -50
  117. package/script/formatter/tab_markers.d.ts +15 -0
  118. package/script/formatter/tab_markers.d.ts.map +1 -0
  119. package/script/formatter/tab_markers.js +141 -0
  120. package/script/gates/mod.d.ts.map +1 -1
  121. package/script/gates/mod.js +15 -14
  122. package/script/lint/runner.d.ts.map +1 -1
  123. package/script/lint/runner.js +3 -3
  124. package/script/lock/check.d.ts.map +1 -1
  125. package/script/lock/check.js +2 -1
  126. package/script/lock/edge_drift.d.ts +2 -0
  127. package/script/lock/edge_drift.d.ts.map +1 -1
  128. package/script/lock/edge_drift.js +5 -0
  129. package/script/lock/mod.d.ts +1 -1
  130. package/script/lock/mod.d.ts.map +1 -1
  131. package/script/lock/mod.js +2 -1
  132. package/script/lock/upstream_deps.js +1 -1
  133. package/script/mod.d.ts +11 -6
  134. package/script/mod.d.ts.map +1 -1
  135. package/script/mod.js +23 -5
  136. package/script/model/mod.d.ts +22 -1
  137. package/script/model/mod.d.ts.map +1 -1
  138. package/script/model/mod.js +11 -0
  139. package/script/parser/code_regions.d.ts +29 -0
  140. package/script/parser/code_regions.d.ts.map +1 -0
  141. package/script/parser/code_regions.js +41 -0
  142. package/script/parser/markdown.d.ts.map +1 -1
  143. package/script/parser/markdown.js +102 -39
  144. package/script/parser/mod.d.ts.map +1 -1
  145. package/script/parser/mod.js +7 -1
  146. package/script/parser/translate.d.ts.map +1 -1
  147. package/script/parser/translate.js +5 -0
  148. package/script/refs/mod.d.ts +6 -2
  149. package/script/refs/mod.d.ts.map +1 -1
  150. package/script/refs/mod.js +14 -20
  151. package/script/reporter/mod.d.ts.map +1 -1
  152. package/script/reporter/mod.js +1 -1
  153. package/script/sync/mapping.d.ts +4 -3
  154. package/script/sync/mapping.d.ts.map +1 -1
  155. package/script/sync/mapping.js +52 -9
  156. package/script/util/display_id.d.ts +20 -0
  157. package/script/util/display_id.d.ts.map +1 -0
  158. package/script/util/display_id.js +22 -0
  159. package/script/util/fence.d.ts +20 -29
  160. package/script/util/fence.d.ts.map +1 -1
  161. package/script/util/fence.js +47 -54
  162. package/script/util/modals.d.ts +6 -0
  163. package/script/util/modals.d.ts.map +1 -1
  164. package/script/util/modals.js +38 -0
  165. package/script/validator/body_blocks.d.ts +2 -1
  166. package/script/validator/body_blocks.d.ts.map +1 -1
  167. package/script/validator/body_blocks.js +80 -2
  168. package/script/validator/corpus.d.ts +6 -0
  169. package/script/validator/corpus.d.ts.map +1 -1
  170. package/script/validator/corpus.js +16 -3
  171. package/script/validator/mod.d.ts +1 -1
  172. package/script/validator/mod.d.ts.map +1 -1
  173. package/script/validator/mod.js +2 -1
  174. package/script/validator/pipeline.d.ts +6 -4
  175. package/script/validator/pipeline.d.ts.map +1 -1
  176. package/script/validator/pipeline.js +24 -19
@@ -19,12 +19,14 @@ export interface PipelineResult {
19
19
  /** Options for {@linkcode runPipeline}. */
20
20
  export interface PipelineOptions {
21
21
  /**
22
- * When `false`, suppress MSL-L006 ("link target does not resolve") from
23
- * Stage 4 output. Use this when the validator is running against a subset
22
+ * When `false`, suppress cross-entry TYPL-009/010/011 from Stage 1,
23
+ * UXIL-016/017/018 from Stage 5, and MSL-L006 ("link target does not
24
+ * resolve") from Stage 4.
25
+ * Use this when the validator is running against a subset
24
26
  * of the project's files (e.g. `markspec check <file>`): file-local scope
25
27
  * cannot distinguish a typo from a valid cross-file target. MSL-L006 is
26
28
  * only meaningful when the full entry set is available (LSP, `compile`).
27
- * Defaults to `true` (full-project scope — emit MSL-L006 normally).
29
+ * Defaults to `true` (full-project scope — emit these codes normally).
28
30
  */
29
31
  readonly projectWide?: boolean;
30
32
  /**
@@ -53,7 +55,7 @@ export interface PipelineOptions {
53
55
  * and non-empty, MSL-C072 is checked for each entry. Defaults to no
54
56
  * conventions (rule inactive).
55
57
  * @param opts - Pipeline options. Pass `{ projectWide: false }` when
56
- * validating a file-local subset so MSL-L006 is suppressed.
58
+ * validating a file-local subset to suppress cross-entry diagnostics.
57
59
  */
58
60
  export declare function runPipeline(entries: readonly Entry[], profile: EffectiveProfile | null, captionConventions?: CaptionConventions, opts?: PipelineOptions): PipelineResult;
59
61
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/validator/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,E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,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;OASG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAE/B;;;;;;;OAOG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,EAChC,kBAAkB,GAAE,kBAAuB,EAC3C,IAAI,GAAE,eAAoB,GACzB,cAAc,CA0JhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,SAAS,UAAU,EAAE,CASvB"}
@@ -23,11 +23,15 @@ import { validateCaptionConvention } from "./caption_convention.js";
23
23
  import { validateDiscipline } from "./discipline.js";
24
24
  import { buildEffectiveDisciplineRegistry } from "../profile/discipline_registry.js";
25
25
  import { validateUxilFamily } from "./uxil_family.js";
26
- /** Cross-entry uxil codes suppressed under file-local scope (#727): a
26
+ /** Cross-entry DSL codes suppressed under file-local scope: a
27
27
  * subset registry cannot distinguish a dangling reference from an
28
28
  * unchecked file — the same false-positive class the MSL-L006 filter
29
- * guards. Entry-local UXIL codes are unaffected. */
30
- const FILE_LOCAL_SUPPRESSED_UXIL = new Set([
29
+ * guards. Suppress these even when the cause is inside the subset,
30
+ * matching uxil's scope policy. Parser diagnostics are unaffected. */
31
+ const FILE_LOCAL_SUPPRESSED_DSL = new Set([
32
+ "TYPL-009",
33
+ "TYPL-010",
34
+ "TYPL-011",
31
35
  "UXIL-016",
32
36
  "UXIL-017",
33
37
  "UXIL-018",
@@ -48,7 +52,7 @@ const FILE_LOCAL_SUPPRESSED_UXIL = new Set([
48
52
  * and non-empty, MSL-C072 is checked for each entry. Defaults to no
49
53
  * conventions (rule inactive).
50
54
  * @param opts - Pipeline options. Pass `{ projectWide: false }` when
51
- * validating a file-local subset so MSL-L006 is suppressed.
55
+ * validating a file-local subset to suppress cross-entry diagnostics.
52
56
  */
53
57
  export function runPipeline(entries, profile, captionConventions = {}, opts = {}) {
54
58
  const diagnostics = [];
@@ -76,7 +80,6 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
76
80
  diagnostics.push(...validateCaptionConvention(entry, captionConventions));
77
81
  diagnostics.push(...validateBodyBlocks(entry));
78
82
  diagnostics.push(...validateFeatureAc(entry));
79
- diagnostics.push(...validatePerTypeAttributes(entry, profile ?? undefined));
80
83
  diagnostics.push(...validateModalKeywords(entry));
81
84
  }
82
85
  // Stage 1.6 — cross-file trace target-type compatibility (MSL-R083).
@@ -102,15 +105,19 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
102
105
  finalEntries = stage2.entries;
103
106
  diagnostics.push(...stage2.diagnostics);
104
107
  }
105
- // Stage 2.4 — late-stage inference warnings (MSL-T021 for steps 5/6).
106
- // Runs after Stage 2 so that profile-classified `entry.type` suppresses
107
- // the warning correctly. In core-only mode `finalEntries === entries`
108
- // and `entry.type` is always undefined, so this stage produces the same
109
- // diagnostics regardless of mode. Partitions inline: `finalEmittable`
110
- // below is derived from the post-normalization generation, which does
111
- // not exist yet at this point.
108
+ // Stage 2.4 — late-stage inference warnings (MSL-T021 for steps 5/6)
109
+ // and per-type attribute compatibility (MSL-T022 / MSL-T024). Both run
110
+ // after Stage 2 so that a profile-classified `entry.type` (display-ID
111
+ // pattern match, no explicit `Type:`) resolves to its `extends:` core
112
+ // type — run before classification, MSL-T024 fired on every
113
+ // pattern-classified entry carrying `Satisfies:`/`Derived-from:`. In
114
+ // core-only mode `finalEntries === entries` and `entry.type` is always
115
+ // undefined, so this stage produces the same diagnostics regardless of
116
+ // mode. Partitions inline: `finalEmittable` below is derived from the
117
+ // post-normalization generation, which does not exist yet at this point.
112
118
  for (const entry of emittableEntries(finalEntries)) {
113
119
  diagnostics.push(...inferTypeFromLateStageChain(entry));
120
+ diagnostics.push(...validatePerTypeAttributes(entry, profile ?? undefined));
114
121
  }
115
122
  // Stage 2.5 — normalize profile-declared list-value attributes. Splits
116
123
  // comma-separated values for `id-list`/`tag-list` attributes the core parser
@@ -166,14 +173,12 @@ export function runPipeline(entries, profile, captionConventions = {}, opts = {}
166
173
  // FULL classified list on purpose: the family derives its own #771
167
174
  // partition and its own declaring/citing split — registry scope is the
168
175
  // module's contract, not this orchestrator's (mirrors validateTypl).
169
- // File-local scope (projectWide: false) suppresses the cross-entry codes
170
- // (UXIL-016/017/018) — a subset registry cannot distinguish a dangling
171
- // reference from an unchecked file, the same false-positive class the
172
- // MSL-L006 suppression guards (#727 review).
173
176
  const uxilDiagnostics = validateUxilFamily(finalEntries, profile);
174
- diagnostics.push(...(projectWide ? uxilDiagnostics : uxilDiagnostics.filter((d) => !FILE_LOCAL_SUPPRESSED_UXIL.has(d.code))));
175
- const valid = !diagnostics.some((d) => d.severity === "error");
176
- return { entries: finalEntries, diagnostics, valid };
177
+ diagnostics.push(...uxilDiagnostics);
178
+ // Apply the same scope policy to Stage 1's typl and Stage 5's uxil.
179
+ const scopedDiagnostics = projectWide ? diagnostics : diagnostics.filter((d) => !FILE_LOCAL_SUPPRESSED_DSL.has(d.code));
180
+ const valid = !scopedDiagnostics.some((d) => d.severity === "error");
181
+ return { entries: finalEntries, diagnostics: scopedDiagnostics, valid };
177
182
  }
178
183
  /**
179
184
  * Drop core Stage 1 `MSL-R010` ("unknown attribute") warnings for attributes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftsys/markspec",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Markdown flavor and toolchain for traceable industrial documentation",
5
5
  "keywords": [
6
6
  "markdown",
@@ -14,11 +14,10 @@
14
14
  * - EARS (`When`, `While`, `Where`, `Unless`) — lowercased
15
15
  * mid-sentence, capitalisation preserved when sentence-initial.
16
16
  *
17
- * The shared `RFC2119_MODAL_RE`, `EARS_KEYWORD_RE`, and `isSentenceInitial`
18
- * helpers are imported from `core/util/modals.ts` (D11 consolidation).
19
- * They cannot be imported from `formatter/mod.ts` because `formatter/`
20
- * depends on `ast/`, making an `ast → formatter` import a dependency cycle.
21
- * `core/util/` is the base level that both modules can import from.
17
+ * The shared `normalizeProseModals` helper is imported from
18
+ * `core/util/modals.ts`. Importing it from `formatter/mod.ts` would create
19
+ * a cycle because `formatter/` already depends on `ast/`.
20
+ * The helper uses only the standalone remark code-region parser.
22
21
  *
23
22
  * Invariants (HARD — never weaken):
24
23
  * - Pure: no `Deno.*`, no I/O.
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/ast/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAQH,OAAO,KAAK,EAEV,SAAS,EASV,MAAM,YAAY,CAAC;AAiJpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,EAAE,CAEb"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/ast/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EAEV,SAAS,EASV,MAAM,YAAY,CAAC;AA+GpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,SAAS,EAAE,GAC3B,SAAS,EAAE,CAEb"}
@@ -15,11 +15,10 @@
15
15
  * - EARS (`When`, `While`, `Where`, `Unless`) — lowercased
16
16
  * mid-sentence, capitalisation preserved when sentence-initial.
17
17
  *
18
- * The shared `RFC2119_MODAL_RE`, `EARS_KEYWORD_RE`, and `isSentenceInitial`
19
- * helpers are imported from `core/util/modals.ts` (D11 consolidation).
20
- * They cannot be imported from `formatter/mod.ts` because `formatter/`
21
- * depends on `ast/`, making an `ast → formatter` import a dependency cycle.
22
- * `core/util/` is the base level that both modules can import from.
18
+ * The shared `normalizeProseModals` helper is imported from
19
+ * `core/util/modals.ts`. Importing it from `formatter/mod.ts` would create
20
+ * a cycle because `formatter/` already depends on `ast/`.
21
+ * The helper uses only the standalone remark code-region parser.
23
22
  *
24
23
  * Invariants (HARD — never weaken):
25
24
  * - Pure: no `Deno.*`, no I/O.
@@ -36,38 +35,8 @@
36
35
  */
37
36
  Object.defineProperty(exports, "__esModule", { value: true });
38
37
  exports.normalizeBodyAst = normalizeBodyAst;
39
- const fence_js_1 = require("../util/fence.js");
40
38
  const modals_js_1 = require("../util/modals.js");
41
39
  // ---------------------------------------------------------------------------
42
- // §3.4.1 string helper — uses shared RFC2119_MODAL_RE, EARS_KEYWORD_RE,
43
- // and isSentenceInitial from core/util/modals.ts (D11 consolidation).
44
- // ---------------------------------------------------------------------------
45
- /**
46
- * Apply the §3.4.1 modal-keyword case rule to a prose string.
47
- *
48
- * Faithful port of `normalizeModalKeywords` (`core/formatter/mod.ts`):
49
- * fenced-code lines are skipped (verbatim, §5.1), and lines indented by
50
- * four or more spaces (or a tab) are skipped (conservatively captures
51
- * indented code blocks / attribute trailers — not prose). On every other
52
- * line, RFC 2119 keywords are lowercased unconditionally and EARS
53
- * keywords are lowercased unless sentence-initial.
54
- *
55
- * Pure and total: never throws; a string with no modal keyword is
56
- * returned unchanged.
57
- */
58
- function normalizeModalsInText(text) {
59
- const lines = text.split("\n");
60
- (0, fence_js_1.walkProseLines)(text, (line, i) => {
61
- // Indented-code / attribute-trailer lines aren't prose either.
62
- if (/^( {4}|\t)/.test(line))
63
- return;
64
- let normalized = line.replace(modals_js_1.RFC2119_MODAL_RE, (m) => m.toLowerCase());
65
- normalized = normalized.replace(modals_js_1.EARS_KEYWORD_RE, (m, _g1, offset) => (0, modals_js_1.isSentenceInitial)(normalized, offset) ? m : m.toLowerCase());
66
- lines[i] = normalized;
67
- });
68
- return lines.join("\n");
69
- }
70
- // ---------------------------------------------------------------------------
71
40
  // InlineContent normalisation
72
41
  // ---------------------------------------------------------------------------
73
42
  /**
@@ -78,7 +47,7 @@ function normalizeModalsInText(text) {
78
47
  * returned UNCHANGED (makes the no-op case allocation-free).
79
48
  */
80
49
  function normalizeInline(content) {
81
- const normalizedText = normalizeModalsInText(content.text);
50
+ const normalizedText = (0, modals_js_1.normalizeProseModals)(content.text);
82
51
  if (normalizedText === content.text)
83
52
  return content;
84
53
  return { text: normalizedText };
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * @module core/collect
3
3
  *
4
- * Project-entry collection: discover every MarkSpec-relevant file under a
5
- * root and parse it into a flat `Entry[]`. The single source of truth for
4
+ * Project-entry collection: discover the MarkSpec-relevant files of one
5
+ * project (a root, minus the projects nested below it) and parse them into
6
+ * a flat `Entry[]`. The single source of truth for
6
7
  * "the set of entries whose trace edges the lockfile pins" — shared by
7
8
  * `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
8
9
  * so they cannot disagree on which files count. Previously each of those
@@ -12,23 +13,42 @@
12
13
  */
13
14
  import type { Entry } from "../model/mod.js";
14
15
  import { type DiscoveryIO } from "../discovery/mod.js";
16
+ /** A discovered project file could not be read. */
17
+ export declare class UnreadableProjectFileError extends Error {
18
+ readonly file: string;
19
+ constructor(file: string);
20
+ }
15
21
  /** Options for {@linkcode collectProjectEntries}. */
16
22
  export interface CollectOptions {
17
- /** Gitignore-syntax patterns (e.g. `project.yaml` `exclude:`), anchored at
18
- * `root`. Applied after `.gitignore` rules. Defaults to none. */
23
+ /** Gitignore-syntax patterns (e.g. `.markspec.yaml` `exclude:`), anchored at
24
+ * `root`. Applied after built-in build-output skips and all `.gitignore`
25
+ * rules at every directory level. Hidden directories are always skipped.
26
+ * Defaults to none. */
19
27
  readonly exclude?: readonly string[];
28
+ /** An enclosing project root whose `.gitignore` files, from it down to
29
+ * `root`, also apply (`discoverFiles` option of the same name). Pass the
30
+ * outermost project root above a nested project, so the nested project
31
+ * pins the files a bare `check` from any folder walks. */
32
+ readonly inheritGitignoreFrom?: string;
33
+ /** Roots of the projects nested below `root`. Their files belong to those
34
+ * projects and are skipped: each `markspec.lock` pins only the entries
35
+ * of its own project. Defaults to none. */
36
+ readonly nestedRoots?: readonly string[];
20
37
  }
21
38
  /**
22
39
  * Walk `root` via {@linkcode discoverFiles} — relying on its default
23
40
  * extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
24
- * depends on — and parse each discovered file, returning the flattened
25
- * entry list. Unreadable files are skipped. Parse diagnostics are not
26
- * surfaced here: this collector exists to give the lockfile pinner and its
27
- * checkers one definition of the file set; callers that need diagnostics
28
- * re-parse.
41
+ * depends on — and parse each discovered file of the project at `root`,
42
+ * returning the flattened entry list. Files below `opts.nestedRoots` are
43
+ * skipped, and `opts.inheritGitignoreFrom` adds the `.gitignore` files of
44
+ * an enclosing project. An unreadable discovered file aborts collection.
45
+ * Parse diagnostics are not surfaced here: this collector exists to give
46
+ * the lockfile pinner and its checkers one definition of the file set;
47
+ * callers that need diagnostics re-parse.
29
48
  *
30
49
  * @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
31
50
  * entry points pass a Deno-backed implementation).
51
+ * @throws {UnreadableProjectFileError} If a discovered project file cannot be read.
32
52
  */
33
53
  export declare function collectProjectEntries(root: string, io: DiscoveryIO, opts?: CollectOptions): Promise<Entry[]>;
34
54
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/collect/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtE,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B;qEACiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,KAAK,EAAE,CAAC,CASlB"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/collect/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAItE,mDAAmD;AACnD,qBAAa,0BAA2B,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIlC;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B;;;2BAGuB;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;8DAG0D;IAC1D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC;;+CAE2C;IAC3C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,KAAK,EAAE,CAAC,CAkBlB"}
@@ -2,8 +2,9 @@
2
2
  /**
3
3
  * @module core/collect
4
4
  *
5
- * Project-entry collection: discover every MarkSpec-relevant file under a
6
- * root and parse it into a flat `Entry[]`. The single source of truth for
5
+ * Project-entry collection: discover the MarkSpec-relevant files of one
6
+ * project (a root, minus the projects nested below it) and parse them into
7
+ * a flat `Entry[]`. The single source of truth for
7
8
  * "the set of entries whose trace edges the lockfile pins" — shared by
8
9
  * `markspec lock` (the pinner) and its checkers (`compile`, `fmt`, `doctor`)
9
10
  * so they cannot disagree on which files count. Previously each of those
@@ -12,27 +13,54 @@
12
13
  * by hand or the lockfile edge-hash comparison would drift spuriously.
13
14
  */
14
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.UnreadableProjectFileError = void 0;
15
17
  exports.collectProjectEntries = collectProjectEntries;
18
+ const path_1 = require("@std/path");
16
19
  const mod_js_1 = require("../discovery/mod.js");
20
+ const projects_js_1 = require("../discovery/projects.js");
17
21
  const mod_js_2 = require("../parser/mod.js");
22
+ /** A discovered project file could not be read. */
23
+ class UnreadableProjectFileError extends Error {
24
+ constructor(file) {
25
+ super(`Cannot read discovered project file: ${file}`);
26
+ Object.defineProperty(this, "file", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: file
31
+ });
32
+ this.name = "UnreadableProjectFileError";
33
+ }
34
+ }
35
+ exports.UnreadableProjectFileError = UnreadableProjectFileError;
18
36
  /**
19
37
  * Walk `root` via {@linkcode discoverFiles} — relying on its default
20
38
  * extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
21
- * depends on — and parse each discovered file, returning the flattened
22
- * entry list. Unreadable files are skipped. Parse diagnostics are not
23
- * surfaced here: this collector exists to give the lockfile pinner and its
24
- * checkers one definition of the file set; callers that need diagnostics
25
- * re-parse.
39
+ * depends on — and parse each discovered file of the project at `root`,
40
+ * returning the flattened entry list. Files below `opts.nestedRoots` are
41
+ * skipped, and `opts.inheritGitignoreFrom` adds the `.gitignore` files of
42
+ * an enclosing project. An unreadable discovered file aborts collection.
43
+ * Parse diagnostics are not surfaced here: this collector exists to give
44
+ * the lockfile pinner and its checkers one definition of the file set;
45
+ * callers that need diagnostics re-parse.
26
46
  *
27
47
  * @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
28
48
  * entry points pass a Deno-backed implementation).
49
+ * @throws {UnreadableProjectFileError} If a discovered project file cannot be read.
29
50
  */
30
51
  async function collectProjectEntries(root, io, opts = {}) {
31
52
  const out = [];
32
- for await (const file of (0, mod_js_1.discoverFiles)(root, io, { exclude: opts.exclude })) {
33
- const content = await io.readFile(file);
34
- if (content === undefined)
53
+ const roots = [root, ...opts.nestedRoots ?? []];
54
+ for await (const file of (0, mod_js_1.discoverFiles)(root, io, {
55
+ exclude: opts.exclude,
56
+ inheritGitignoreFrom: opts.inheritGitignoreFrom,
57
+ })) {
58
+ if ((0, projects_js_1.nearestRoot)((0, path_1.dirname)(file), roots) !== root)
35
59
  continue;
60
+ const content = await io.readFile(file);
61
+ if (content === undefined) {
62
+ throw new UnreadableProjectFileError(file);
63
+ }
36
64
  const result = await (0, mod_js_2.parseFile)(content, { file });
37
65
  out.push(...result.entries);
38
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/compiler/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,gBAAgB,EAChB,KAAK,EAEL,IAAI,EAEL,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOtE,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,qGAAqG;IACrG,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAClB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;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AAC,EAAE,SAAS,KAAK,EAAE,CAAC;CAC3C;AAkED,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChD,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAC1D,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IAC1D,4GAA4G;IAC5G,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClD,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;CACrC;AA4BD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAoMxB;AA+ED,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EACV,uBAAuB,EACvB,eAAe,EACf,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
@@ -264,11 +264,7 @@ async function compile(paths, options) {
264
264
  // bugs they cannot fix. No-op (and zero allocation beyond the spread
265
265
  // above) when no corpus was injected.
266
266
  if (options.corpusEntries && options.corpusEntries.length > 0) {
267
- const collisions = (0, mod_js_3.detectCorpusCollisions)(allEntries);
268
- diagnostics = [
269
- ...(0, mod_js_3.attributeCorpusDiagnostics)(diagnostics, allEntries, collisions.collidedTokens),
270
- ...collisions.diagnostics,
271
- ];
267
+ diagnostics = (0, mod_js_3.applyCorpusPostPass)(diagnostics, allEntries);
272
268
  }
273
269
  return {
274
270
  entries,
@@ -47,13 +47,15 @@ export interface MarkspecYaml {
47
47
  /**
48
48
  * Gitignore-syntax patterns excluded from project file discovery,
49
49
  * anchored at the project root (e.g. `["skills/", "*.gen.md"]`).
50
- * Applied after `.gitignore` rules by `core/discovery`. Defaults to
51
- * `[]` when the key is absent.
50
+ * Applied after built-in build-output skips and all `.gitignore` rules at
51
+ * every directory level by `core/discovery`. Negations can re-include
52
+ * non-hidden directories, provided their parents are not ignored. Hidden
53
+ * directories are always skipped. Defaults to `[]` when the key is absent or null.
52
54
  */
53
55
  readonly exclude: readonly string[];
54
56
  /**
55
57
  * Per-keyword caption-position conventions (spec §4.7 MSL-C072).
56
- * Defaults to `{}` when the key is absent.
58
+ * Defaults to `{}` when the key is absent or null.
57
59
  */
58
60
  readonly captionConventions: CaptionConventions;
59
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"markspec.d.ts","sourceRoot":"","sources":["../../src/config/markspec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAElB,UAAU,EACV,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAIxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAA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Q,EAAE,QAAQ,GACjB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AA8DD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,aAAa,CA4Hf;AAwID;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAMD;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAUvC"}
@@ -13,6 +13,7 @@ exports.deriveDomain = deriveDomain;
13
13
  exports.loadConfig = loadConfig;
14
14
  const yaml_1 = require("@std/yaml");
15
15
  const path_1 = require("@std/path");
16
+ const formats_js_1 = require("ajv-formats/dist/formats.js");
16
17
  const mod_js_1 = require("../model/mod.js");
17
18
  /** The config file name used as the project root marker. */
18
19
  exports.CONFIG_FILE_NAME = "project.yaml";
@@ -150,12 +151,24 @@ function parseProjectConfig(yaml, filePath) {
150
151
  // version: required string (org project schema)
151
152
  let version = mod_js_1.DEFAULT_PROJECT_CONFIG.version;
152
153
  if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
153
- if (typeof obj.version === "number") {
154
+ if (typeof obj.version === "string") {
155
+ version = obj.version;
156
+ }
157
+ else if (typeof obj.version === "number") {
158
+ // Existing tests and the guide require numeric-version coercion.
159
+ // This remains an exception to the org schema's string-only rule.
154
160
  console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
155
161
  `coerced to "${String(obj.version)}". ` +
156
162
  `Quote it in YAML: version: "${obj.version}"`);
163
+ version = String(obj.version);
164
+ }
165
+ else {
166
+ errors.push({
167
+ field: "version",
168
+ message: `expected string, got ${typeof obj.version}`,
169
+ line: findLineNumber(yaml, "version"),
170
+ });
157
171
  }
158
- version = String(obj.version);
159
172
  }
160
173
  else {
161
174
  errors.push({
@@ -200,6 +213,8 @@ function parseProjectConfig(yaml, filePath) {
200
213
  /** Safe upstream id: single path segment, no separators or traversal. */
201
214
  const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
202
215
  const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
216
+ // ajv-formats provides the RFC 3986 URI validator used by schema validation.
217
+ const isUri = formats_js_1.fullFormats.uri;
203
218
  /**
204
219
  * Parse a `dependencies:` or `references:` list of projectRef objects
205
220
  * (`{ url (required), version?, name? }`). Pushes field errors onto
@@ -208,7 +223,7 @@ const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
208
223
  * mask other unrelated errors.
209
224
  */
210
225
  function parseProjectRefList(value, field, yaml, errors) {
211
- if (value === undefined || value === null)
226
+ if (value === undefined)
212
227
  return [];
213
228
  if (!Array.isArray(value)) {
214
229
  errors.push({
@@ -218,6 +233,13 @@ function parseProjectRefList(value, field, yaml, errors) {
218
233
  });
219
234
  return [];
220
235
  }
236
+ if (value.length === 0) {
237
+ errors.push({
238
+ field,
239
+ message: "must contain at least one projectRef when present",
240
+ line: findLineNumber(yaml, field),
241
+ });
242
+ }
221
243
  const out = [];
222
244
  value.forEach((item, i) => {
223
245
  if (typeof item !== "object" || item === null || Array.isArray(item)) {
@@ -247,12 +269,24 @@ function parseProjectRefList(value, field, yaml, errors) {
247
269
  });
248
270
  return;
249
271
  }
272
+ // Local paths and scp-style Git URLs are required by existing tests and
273
+ // documentation, although the org schema's URI format rejects them.
274
+ const isGitLocation = field === "dependencies" && (url.startsWith("./") || url.startsWith("../") || url.startsWith("/") ||
275
+ /^[A-Za-z]:\\/.test(url) ||
276
+ /^[^@/:\s]+@[^/:\s]+:[^\s]+$/.test(url));
277
+ if (!isUri(url) && !isGitLocation) {
278
+ errors.push({
279
+ field: `${field}[${i}].url`,
280
+ message: "must be a URI",
281
+ line: findLineNumber(yaml, field),
282
+ });
283
+ }
250
284
  const ref = { url };
251
285
  if (record.version !== undefined) {
252
- if (typeof record.version !== "string" || record.version.length === 0) {
286
+ if (typeof record.version !== "string") {
253
287
  errors.push({
254
288
  field: `${field}[${i}].version`,
255
- message: "must be a non-empty string when present",
289
+ message: "must be a string when present",
256
290
  line: findLineNumber(yaml, field),
257
291
  });
258
292
  }
@@ -273,6 +307,14 @@ function parseProjectRefList(value, field, yaml, errors) {
273
307
  ref.name = record.name;
274
308
  }
275
309
  }
310
+ if (out.some((previous) => previous.url === ref.url && previous.version === ref.version &&
311
+ previous.name === ref.name)) {
312
+ errors.push({
313
+ field: `${field}[${i}]`,
314
+ message: "duplicate projectRef; list items must be unique",
315
+ line: findLineNumber(yaml, field),
316
+ });
317
+ }
276
318
  out.push(ref);
277
319
  });
278
320
  return out;
@@ -1,14 +1,18 @@
1
1
  /**
2
2
  * @module core/discovery
3
3
  *
4
- * Gitignore-aware project file discovery — the single walker every
5
- * MarkSpec surface uses (CLI verbs, LSP indexing, lockfile entry
6
- * collection). Yields absolute paths of MarkSpec-relevant files under a
7
- * root, honoring (in precedence order):
4
+ * Gitignore-aware project file discovery shared by CLI scope resolution,
5
+ * LSP indexing, lockfile entry collection and nested-project discovery.
6
+ * Yields absolute paths of MarkSpec-relevant files under a
7
+ * root, unconditionally skipping hidden directories and honoring (in
8
+ * precedence order):
8
9
  *
9
- * 1. built-in skips — hidden directories (name starts with `.`)
10
- * 2. `.gitignore` files (root + nested, standard semantics)
11
- * 3. caller-supplied `exclude` patterns (gitignore syntax, root-anchored)
10
+ * 1. built-in skips — common build-output directories
11
+ * 2. `.gitignore` files (root + nested, standard semantics), plus, when
12
+ * the caller names an enclosing folder, the `.gitignore` files of the
13
+ * folders from that folder down to the root's parent
14
+ * 3. caller-supplied `exclude` patterns (gitignore syntax, root-anchored),
15
+ * applied last at every directory level, including for negations
12
16
  *
13
17
  * I/O is injected via {@linkcode DiscoveryIO} so the module stays
14
18
  * Node-compatible; entry points supply the Deno implementation.
@@ -42,8 +46,20 @@ export interface DiscoverOptions {
42
46
  /** Extension filter; defaults to {@linkcode RELEVANT_EXTENSIONS}. */
43
47
  readonly extensions?: ReadonlySet<string>;
44
48
  /** Extra gitignore-syntax patterns, anchored at `root` (e.g. from
45
- * project.yaml `exclude:`). Applied after `.gitignore` rules. */
49
+ * `.markspec.yaml` `exclude:`). Applied after built-in build-output skips and
50
+ * `.gitignore` rules at every directory level. Negations can re-include
51
+ * non-hidden directories; an ignored parent must also be re-included. */
46
52
  readonly exclude?: readonly string[];
53
+ /**
54
+ * An enclosing folder of `root`, such as the root of the project that a
55
+ * nested project lies in. The `.gitignore` files of the folders from it
56
+ * down to the parent of `root` also apply, each anchored to its own
57
+ * folder, so the walk of a nested project skips the files that those
58
+ * `.gitignore` files ignore. Only `.gitignore` files are inherited, not
59
+ * the enclosing folder's `exclude` patterns. No `.gitignore` above this
60
+ * folder is read. Ignored when it is not a strict ancestor of `root`.
61
+ */
62
+ readonly inheritGitignoreFrom?: string;
47
63
  }
48
64
  /**
49
65
  * Walk `root` recursively, yielding absolute paths of relevant files.
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/discovery/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,KAAK,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAmBhD,CAAC;AAEH,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAoB,CAAC;AAEzE,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAGlD,CAAC;AAEH;mDACmD;AACnD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B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