@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
package/README.md CHANGED
@@ -165,6 +165,15 @@ fn swt_brk_0001_debounce_filters_noise() {
165
165
  **Mustache variables** — `{{project.name}}` substitution from `project.yaml`,
166
166
  resolved at build time.
167
167
 
168
+ ## MarkDesk
169
+
170
+ MarkDesk is a desktop authoring app for MarkSpec products. It lives in
171
+ [`apps/markdesk`](apps/markdesk/README.md): a React and Vite UI in a Tauri v2
172
+ shell. The app starts `markspec desk --serve` as a sidecar and reads the product
173
+ through that local API. It writes an entry body only after the author accepts an
174
+ assistant's proposal. MarkDesk is in development and is not yet released. The
175
+ design is recorded in [ADR-035](docs/architecture/adr-035-markdesk.md).
176
+
168
177
  ## Install
169
178
 
170
179
  See [`docs/guide/installation.md`](docs/guide/installation.md) for the VS Code
@@ -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"}
@@ -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.
@@ -33,37 +32,7 @@
33
32
  *
34
33
  * This module is pure library code: no `Deno.*` APIs.
35
34
  */
36
- import { walkProseLines } from "../util/fence.js";
37
- import { EARS_KEYWORD_RE, isSentenceInitial, RFC2119_MODAL_RE, } from "../util/modals.js";
38
- // ---------------------------------------------------------------------------
39
- // §3.4.1 string helper — uses shared RFC2119_MODAL_RE, EARS_KEYWORD_RE,
40
- // and isSentenceInitial from core/util/modals.ts (D11 consolidation).
41
- // ---------------------------------------------------------------------------
42
- /**
43
- * Apply the §3.4.1 modal-keyword case rule to a prose string.
44
- *
45
- * Faithful port of `normalizeModalKeywords` (`core/formatter/mod.ts`):
46
- * fenced-code lines are skipped (verbatim, §5.1), and lines indented by
47
- * four or more spaces (or a tab) are skipped (conservatively captures
48
- * indented code blocks / attribute trailers — not prose). On every other
49
- * line, RFC 2119 keywords are lowercased unconditionally and EARS
50
- * keywords are lowercased unless sentence-initial.
51
- *
52
- * Pure and total: never throws; a string with no modal keyword is
53
- * returned unchanged.
54
- */
55
- function normalizeModalsInText(text) {
56
- const lines = text.split("\n");
57
- walkProseLines(text, (line, i) => {
58
- // Indented-code / attribute-trailer lines aren't prose either.
59
- if (/^( {4}|\t)/.test(line))
60
- return;
61
- let normalized = line.replace(RFC2119_MODAL_RE, (m) => m.toLowerCase());
62
- normalized = normalized.replace(EARS_KEYWORD_RE, (m, _g1, offset) => isSentenceInitial(normalized, offset) ? m : m.toLowerCase());
63
- lines[i] = normalized;
64
- });
65
- return lines.join("\n");
66
- }
35
+ import { normalizeProseModals } from "../util/modals.js";
67
36
  // ---------------------------------------------------------------------------
68
37
  // InlineContent normalisation
69
38
  // ---------------------------------------------------------------------------
@@ -75,7 +44,7 @@ function normalizeModalsInText(text) {
75
44
  * returned UNCHANGED (makes the no-op case allocation-free).
76
45
  */
77
46
  function normalizeInline(content) {
78
- const normalizedText = normalizeModalsInText(content.text);
47
+ const normalizedText = normalizeProseModals(content.text);
79
48
  if (normalizedText === content.text)
80
49
  return content;
81
50
  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"}
@@ -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
@@ -10,26 +11,51 @@
10
11
  * private helper the others reached into), which had to stay byte-identical
11
12
  * by hand or the lockfile edge-hash comparison would drift spuriously.
12
13
  */
14
+ import { dirname } from "@std/path";
13
15
  import { discoverFiles } from "../discovery/mod.js";
16
+ import { nearestRoot } from "../discovery/projects.js";
14
17
  import { parseFile } from "../parser/mod.js";
18
+ /** A discovered project file could not be read. */
19
+ export class UnreadableProjectFileError extends Error {
20
+ constructor(file) {
21
+ super(`Cannot read discovered project file: ${file}`);
22
+ Object.defineProperty(this, "file", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: file
27
+ });
28
+ this.name = "UnreadableProjectFileError";
29
+ }
30
+ }
15
31
  /**
16
32
  * Walk `root` via {@linkcode discoverFiles} — relying on its default
17
33
  * extension set (`RELEVANT_EXTENSIONS`), the parity point every caller
18
- * depends on — and parse each discovered file, returning the flattened
19
- * entry list. Unreadable files are skipped. Parse diagnostics are not
20
- * surfaced here: this collector exists to give the lockfile pinner and its
21
- * checkers one definition of the file set; callers that need diagnostics
22
- * re-parse.
34
+ * depends on — and parse each discovered file of the project at `root`,
35
+ * returning the flattened entry list. Files below `opts.nestedRoots` are
36
+ * skipped, and `opts.inheritGitignoreFrom` adds the `.gitignore` files of
37
+ * an enclosing project. An unreadable discovered file aborts collection.
38
+ * Parse diagnostics are not surfaced here: this collector exists to give
39
+ * the lockfile pinner and its checkers one definition of the file set;
40
+ * callers that need diagnostics re-parse.
23
41
  *
24
42
  * @param io Injected filesystem surface (keeps `core/` Node-compatible; CLI
25
43
  * entry points pass a Deno-backed implementation).
44
+ * @throws {UnreadableProjectFileError} If a discovered project file cannot be read.
26
45
  */
27
46
  export async function collectProjectEntries(root, io, opts = {}) {
28
47
  const out = [];
29
- for await (const file of discoverFiles(root, io, { exclude: opts.exclude })) {
30
- const content = await io.readFile(file);
31
- if (content === undefined)
48
+ const roots = [root, ...opts.nestedRoots ?? []];
49
+ for await (const file of discoverFiles(root, io, {
50
+ exclude: opts.exclude,
51
+ inheritGitignoreFrom: opts.inheritGitignoreFrom,
52
+ })) {
53
+ if (nearestRoot(dirname(file), roots) !== root)
32
54
  continue;
55
+ const content = await io.readFile(file);
56
+ if (content === undefined) {
57
+ throw new UnreadableProjectFileError(file);
58
+ }
33
59
  const result = await parseFile(content, { file });
34
60
  out.push(...result.entries);
35
61
  }
@@ -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,QAA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E,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"}
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { makeDisplayId } from "../model/mod.js";
8
8
  import { parseFile } from "../parser/mod.js";
9
- import { attributeCorpusDiagnostics, classifyEntriesStage, detectCorpusCollisions, suppressDeclaredAttrR010, validate, } from "../validator/mod.js";
9
+ import { applyCorpusPostPass, classifyEntriesStage, suppressDeclaredAttrR010, validate, } from "../validator/mod.js";
10
10
  import { validateUxilFamily } from "../validator/uxil_family.js";
11
11
  import { buildTypeRegistry } from "../typl/mod.js";
12
12
  import { buildEffectiveDisciplineRegistry } from "../profile/discipline_registry.js";
@@ -260,11 +260,7 @@ export async function compile(paths, options) {
260
260
  // bugs they cannot fix. No-op (and zero allocation beyond the spread
261
261
  // above) when no corpus was injected.
262
262
  if (options.corpusEntries && options.corpusEntries.length > 0) {
263
- const collisions = detectCorpusCollisions(allEntries);
264
- diagnostics = [
265
- ...attributeCorpusDiagnostics(diagnostics, allEntries, collisions.collidedTokens),
266
- ...collisions.diagnostics,
267
- ];
263
+ diagnostics = applyCorpusPostPass(diagnostics, allEntries);
268
264
  }
269
265
  return {
270
266
  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,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AAMD,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CACjD;AAED,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EA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/config/mod.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { parse as parseYaml } from "@std/yaml";
8
8
  import { dirname, join, resolve } from "@std/path";
9
+ import { fullFormats } from "ajv-formats/dist/formats.js";
9
10
  import { ConfigError, DEFAULT_PROJECT_CONFIG, } from "../model/mod.js";
10
11
  /** The config file name used as the project root marker. */
11
12
  export const CONFIG_FILE_NAME = "project.yaml";
@@ -143,12 +144,24 @@ export function parseProjectConfig(yaml, filePath) {
143
144
  // version: required string (org project schema)
144
145
  let version = DEFAULT_PROJECT_CONFIG.version;
145
146
  if (obj.version !== undefined && obj.version !== null && obj.version !== "") {
146
- if (typeof obj.version === "number") {
147
+ if (typeof obj.version === "string") {
148
+ version = obj.version;
149
+ }
150
+ else if (typeof obj.version === "number") {
151
+ // Existing tests and the guide require numeric-version coercion.
152
+ // This remains an exception to the org schema's string-only rule.
147
153
  console.error(`warning: ${filePath}: version is a number (${obj.version}), ` +
148
154
  `coerced to "${String(obj.version)}". ` +
149
155
  `Quote it in YAML: version: "${obj.version}"`);
156
+ version = String(obj.version);
157
+ }
158
+ else {
159
+ errors.push({
160
+ field: "version",
161
+ message: `expected string, got ${typeof obj.version}`,
162
+ line: findLineNumber(yaml, "version"),
163
+ });
150
164
  }
151
- version = String(obj.version);
152
165
  }
153
166
  else {
154
167
  errors.push({
@@ -193,6 +206,8 @@ export function parseProjectConfig(yaml, filePath) {
193
206
  /** Safe upstream id: single path segment, no separators or traversal. */
194
207
  const PROJECT_REF_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
195
208
  const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
209
+ // ajv-formats provides the RFC 3986 URI validator used by schema validation.
210
+ const isUri = fullFormats.uri;
196
211
  /**
197
212
  * Parse a `dependencies:` or `references:` list of projectRef objects
198
213
  * (`{ url (required), version?, name? }`). Pushes field errors onto
@@ -201,7 +216,7 @@ const PROJECT_REF_KEYS = new Set(["url", "version", "name"]);
201
216
  * mask other unrelated errors.
202
217
  */
203
218
  function parseProjectRefList(value, field, yaml, errors) {
204
- if (value === undefined || value === null)
219
+ if (value === undefined)
205
220
  return [];
206
221
  if (!Array.isArray(value)) {
207
222
  errors.push({
@@ -211,6 +226,13 @@ function parseProjectRefList(value, field, yaml, errors) {
211
226
  });
212
227
  return [];
213
228
  }
229
+ if (value.length === 0) {
230
+ errors.push({
231
+ field,
232
+ message: "must contain at least one projectRef when present",
233
+ line: findLineNumber(yaml, field),
234
+ });
235
+ }
214
236
  const out = [];
215
237
  value.forEach((item, i) => {
216
238
  if (typeof item !== "object" || item === null || Array.isArray(item)) {
@@ -240,12 +262,24 @@ function parseProjectRefList(value, field, yaml, errors) {
240
262
  });
241
263
  return;
242
264
  }
265
+ // Local paths and scp-style Git URLs are required by existing tests and
266
+ // documentation, although the org schema's URI format rejects them.
267
+ const isGitLocation = field === "dependencies" && (url.startsWith("./") || url.startsWith("../") || url.startsWith("/") ||
268
+ /^[A-Za-z]:\\/.test(url) ||
269
+ /^[^@/:\s]+@[^/:\s]+:[^\s]+$/.test(url));
270
+ if (!isUri(url) && !isGitLocation) {
271
+ errors.push({
272
+ field: `${field}[${i}].url`,
273
+ message: "must be a URI",
274
+ line: findLineNumber(yaml, field),
275
+ });
276
+ }
243
277
  const ref = { url };
244
278
  if (record.version !== undefined) {
245
- if (typeof record.version !== "string" || record.version.length === 0) {
279
+ if (typeof record.version !== "string") {
246
280
  errors.push({
247
281
  field: `${field}[${i}].version`,
248
- message: "must be a non-empty string when present",
282
+ message: "must be a string when present",
249
283
  line: findLineNumber(yaml, field),
250
284
  });
251
285
  }
@@ -266,6 +300,14 @@ function parseProjectRefList(value, field, yaml, errors) {
266
300
  ref.name = record.name;
267
301
  }
268
302
  }
303
+ if (out.some((previous) => previous.url === ref.url && previous.version === ref.version &&
304
+ previous.name === ref.name)) {
305
+ errors.push({
306
+ field: `${field}[${i}]`,
307
+ message: "duplicate projectRef; list items must be unique",
308
+ line: findLineNumber(yaml, field),
309
+ });
310
+ }
269
311
  out.push(ref);
270
312
  });
271
313
  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;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACxD,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACrD;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C;qEACiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MA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AAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AA8BD;;;;GAIG;AACH,wBAAuB,aAAa,CAClC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,CAAC,CAsBxB"}
@@ -1,19 +1,23 @@
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.
15
19
  */
16
- import { extname, join } from "@std/path";
20
+ import { extname, join, relative, resolve, SEPARATOR } from "@std/path";
17
21
  import { isIgnored, parseGitignore } from "./gitignore.js";
18
22
  export { isIgnored, parseGitignore } from "./gitignore.js";
19
23
  /**
@@ -58,9 +62,9 @@ export const RELEVANT_EXTENSIONS = new Set([
58
62
  * indexing, spurious `MSL-L212` edge-hash entries).
59
63
  *
60
64
  * Unlike the hidden-dir skip these are overridable: they are applied as the
61
- * LOWEST-precedence rule layer (before `.gitignore` and `exclude:`), so a
62
- * negated `!target/` entry in either re-includes them under gitignore
63
- * last-match-wins.
65
+ * lowest-precedence rule layer (before `.gitignore` and `exclude:`), so a
66
+ * negated `!target/` entry in either re-includes that directory under
67
+ * gitignore last-match-wins.
64
68
  */
65
69
  const BUILTIN_SKIP_DIRS = [
66
70
  "node_modules",
@@ -78,19 +82,51 @@ const BUILTIN_SKIP_RULES = parseGitignore(BUILTIN_SKIP_DIRS.map((d) => `${d}/`).
78
82
  */
79
83
  export async function* discoverFiles(root, io, options = {}) {
80
84
  const extensions = options.extensions ?? RELEVANT_EXTENSIONS;
81
- const excludeRules = parseGitignore((options.exclude ?? []).join("\n"), "");
82
- // Built-in build-output skips are the lowest-precedence layer: `.gitignore`
83
- // (appended per-directory in `walk`) and `exclude:` both come after, so a
84
- // `!target/` negation in either overrides them.
85
- yield* walk(root, "", [...BUILTIN_SKIP_RULES, ...excludeRules], io, extensions);
85
+ const inherited = options.inheritGitignoreFrom === undefined
86
+ ? { rules: [], prefix: "" }
87
+ : await inheritedGitignoreRules(options.inheritGitignoreFrom, root, io);
88
+ // With inherited rules, every rule is matched against paths relative to
89
+ // the enclosing folder, so `prefix` is the path from it down to `root`.
90
+ const prefix = inherited.prefix;
91
+ const excludeRules = parseGitignore((options.exclude ?? []).join("\n"), prefix);
92
+ // Carry excludes separately: they must stay after every `.gitignore`,
93
+ // including ones loaded deeper in the walk.
94
+ yield* walk(root, prefix, [...BUILTIN_SKIP_RULES, ...inherited.rules], excludeRules, io, extensions);
86
95
  }
87
- async function* walk(absDir, relDir, rules, io, extensions) {
88
- // Nested .gitignore rules append after inherited ones — deeper rules
89
- // win under last-match-wins.
96
+ /**
97
+ * Collect the `.gitignore` rules of the folders from `from` down to the
98
+ * parent of `root`, outermost first, each anchored to its own folder.
99
+ * Returns them with the POSIX path from `from` down to `root`. Returns no
100
+ * rules and an empty path when `from` is not a strict ancestor of `root`.
101
+ */
102
+ async function inheritedGitignoreRules(from, root, io) {
103
+ const rel = relative(resolve(from), resolve(root));
104
+ if (rel === "" || rel === ".." || rel.startsWith(`..${SEPARATOR}`)) {
105
+ return { rules: [], prefix: "" };
106
+ }
107
+ const segments = rel.split(SEPARATOR);
108
+ const rules = [];
109
+ for (let i = 0; i < segments.length; i++) {
110
+ const raw = await io.readFile(join(from, ...segments.slice(0, i), ".gitignore"));
111
+ if (raw === undefined || raw.length === 0)
112
+ continue;
113
+ rules.push(...parseGitignore(raw, segments.slice(0, i).join("/")));
114
+ }
115
+ return { rules, prefix: segments.join("/") };
116
+ }
117
+ /**
118
+ * Walk `absDir`. `relDir` is the POSIX path of `absDir` relative to the
119
+ * folder the rules are anchored at (the enclosing folder when rules are
120
+ * inherited, else the walk root); `""` for that folder itself.
121
+ */
122
+ async function* walk(absDir, relDir, rules, excludeRules, io, extensions) {
123
+ // Deeper `.gitignore` rules win over inherited ones. Excludes stay last
124
+ // for this directory's decisions, but are not inherited as gitignore rules.
90
125
  const raw = await io.readFile(join(absDir, ".gitignore"));
91
- const active = raw !== undefined && raw.length > 0
126
+ const gitignoreRules = raw !== undefined && raw.length > 0
92
127
  ? [...rules, ...parseGitignore(raw, relDir)]
93
128
  : rules;
129
+ const active = [...gitignoreRules, ...excludeRules];
94
130
  const entries = [];
95
131
  try {
96
132
  for await (const e of io.readDir(absDir))
@@ -109,7 +145,7 @@ async function* walk(absDir, relDir, rules, io, extensions) {
109
145
  // re-included, so pruning here is correct (and fast).
110
146
  if (isIgnored(rel, true, active))
111
147
  continue;
112
- yield* walk(join(absDir, entry.name), rel, active, io, extensions);
148
+ yield* walk(join(absDir, entry.name), rel, gitignoreRules, excludeRules, io, extensions);
113
149
  }
114
150
  else if (entry.isFile) {
115
151
  if (!extensions.has(extname(entry.name).toLowerCase()))