@canonical/pragma-cli 0.35.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +2 -2
  2. package/bundled-skills/add-standard/SKILL.md +338 -0
  3. package/bundled-skills/adoption-a1-styles/SKILL.md +269 -0
  4. package/bundled-skills/adoption-a2-components/SKILL.md +291 -0
  5. package/bundled-skills/adoption-a3-forms/SKILL.md +260 -0
  6. package/bundled-skills/anatomy-author/ANATOMY_DSL_SPEC.md +406 -0
  7. package/bundled-skills/anatomy-author/SKILL.md +1226 -0
  8. package/bundled-skills/design-auditor/SKILL.md +455 -0
  9. package/bundled-skills/implement-component/SKILL.md +333 -0
  10. package/bundled-skills/specify-component/SKILL.md +331 -0
  11. package/bundled-skills/specify-pattern/SKILL.md +292 -0
  12. package/dist/package.json +16 -15
  13. package/dist/pragma.conf.js +236 -34
  14. package/dist/pragma.conf.js.map +1 -1
  15. package/dist/src/bin.js +1 -1
  16. package/dist/src/bin.js.map +1 -1
  17. package/dist/src/capabilities/colophon/colophon.render.js +1 -1
  18. package/dist/src/capabilities/colophon/colophon.render.js.map +1 -1
  19. package/dist/src/capabilities/create/mount.js +4 -3
  20. package/dist/src/capabilities/create/mount.js.map +1 -1
  21. package/dist/src/capabilities/doctor/checks/checkPackageRefs.js +60 -4
  22. package/dist/src/capabilities/doctor/checks/checkPackageRefs.js.map +1 -1
  23. package/dist/src/capabilities/doctor/checks/checkShellCompletions.js +8 -8
  24. package/dist/src/capabilities/doctor/checks/checkShellCompletions.js.map +1 -1
  25. package/dist/src/capabilities/doctor/checks/harnessInventory.js +195 -0
  26. package/dist/src/capabilities/doctor/checks/harnessInventory.js.map +1 -0
  27. package/dist/src/capabilities/doctor/checks/index.js +6 -6
  28. package/dist/src/capabilities/doctor/checks/targetHealth.js +194 -50
  29. package/dist/src/capabilities/doctor/checks/targetHealth.js.map +1 -1
  30. package/dist/src/capabilities/doctor/doctor.render.js +43 -64
  31. package/dist/src/capabilities/doctor/doctor.render.js.map +1 -1
  32. package/dist/src/capabilities/doctor/doctor.verb.js +6 -2
  33. package/dist/src/capabilities/doctor/doctor.verb.js.map +1 -1
  34. package/dist/src/capabilities/doctor/runChecks.js +14 -11
  35. package/dist/src/capabilities/doctor/runChecks.js.map +1 -1
  36. package/dist/src/capabilities/graph/query.render.js +2 -2
  37. package/dist/src/capabilities/graph/query.render.js.map +1 -1
  38. package/dist/src/capabilities/info/collectInfo.js +8 -2
  39. package/dist/src/capabilities/info/collectInfo.js.map +1 -1
  40. package/dist/src/capabilities/info/info.render.js +6 -2
  41. package/dist/src/capabilities/info/info.render.js.map +1 -1
  42. package/dist/src/capabilities/prompt/prompt.render.js +2 -2
  43. package/dist/src/capabilities/prompt/prompt.render.js.map +1 -1
  44. package/dist/src/capabilities/setup/buildPlan.js +43 -39
  45. package/dist/src/capabilities/setup/buildPlan.js.map +1 -1
  46. package/dist/src/capabilities/setup/mode.js +2 -2
  47. package/dist/src/capabilities/setup/operations/index.js +4 -4
  48. package/dist/src/capabilities/setup/operations/index.js.map +1 -1
  49. package/dist/src/capabilities/setup/operations/setupGenerator.js +92 -45
  50. package/dist/src/capabilities/setup/operations/setupGenerator.js.map +1 -1
  51. package/dist/src/capabilities/setup/operations/setupLsp.js +88 -36
  52. package/dist/src/capabilities/setup/operations/setupLsp.js.map +1 -1
  53. package/dist/src/capabilities/setup/operations/setupMcp.js +97 -51
  54. package/dist/src/capabilities/setup/operations/setupMcp.js.map +1 -1
  55. package/dist/src/capabilities/setup/operations/setupSkills.js +325 -47
  56. package/dist/src/capabilities/setup/operations/setupSkills.js.map +1 -1
  57. package/dist/src/capabilities/setup/plan.js.map +1 -1
  58. package/dist/src/capabilities/setup/plan.render.js +144 -66
  59. package/dist/src/capabilities/setup/plan.render.js.map +1 -1
  60. package/dist/src/capabilities/setup/setup.render.js +1 -1
  61. package/dist/src/capabilities/setup/setup.verb.js +86 -33
  62. package/dist/src/capabilities/setup/setup.verb.js.map +1 -1
  63. package/dist/src/capabilities/setup/targets.js +110 -45
  64. package/dist/src/capabilities/setup/targets.js.map +1 -1
  65. package/dist/src/capabilities/shared/index.js +6 -5
  66. package/dist/src/capabilities/shared/index.js.map +1 -1
  67. package/dist/src/capabilities/shared/packageManager.js +300 -54
  68. package/dist/src/capabilities/shared/packageManager.js.map +1 -1
  69. package/dist/src/capabilities/skill/discover.js +97 -11
  70. package/dist/src/capabilities/skill/discover.js.map +1 -1
  71. package/dist/src/capabilities/skill/render.js +2 -2
  72. package/dist/src/capabilities/skill/render.js.map +1 -1
  73. package/dist/src/capabilities/sources/installSkills.js +145 -3
  74. package/dist/src/capabilities/sources/installSkills.js.map +1 -1
  75. package/dist/src/capabilities/sources/runUpdate.js +68 -2
  76. package/dist/src/capabilities/sources/runUpdate.js.map +1 -1
  77. package/dist/src/capabilities/sources/update.verb.js +3 -3
  78. package/dist/src/capabilities/sources/update.verb.js.map +1 -1
  79. package/dist/src/capabilities/upgrade/runUpgrade.js +43 -7
  80. package/dist/src/capabilities/upgrade/runUpgrade.js.map +1 -1
  81. package/dist/src/capabilities/upgrade/upgrade.render.js +10 -2
  82. package/dist/src/capabilities/upgrade/upgrade.render.js.map +1 -1
  83. package/dist/src/constants.js +6 -1
  84. package/dist/src/constants.js.map +1 -1
  85. package/dist/src/kernel/index.js +11 -2
  86. package/dist/src/kernel/index.js.map +1 -1
  87. package/dist/src/kernel/interactivity.js +68 -0
  88. package/dist/src/kernel/interactivity.js.map +1 -0
  89. package/dist/src/kernel/packs/renderPack.js +3 -3
  90. package/dist/src/kernel/packs/renderPack.js.map +1 -1
  91. package/dist/src/kernel/packs/resolveEntity.js +63 -12
  92. package/dist/src/kernel/packs/resolveEntity.js.map +1 -1
  93. package/dist/src/kernel/packs/runBodies.js +57 -4
  94. package/dist/src/kernel/packs/runBodies.js.map +1 -1
  95. package/dist/src/kernel/packs/schema.js +54 -2
  96. package/dist/src/kernel/packs/schema.js.map +1 -1
  97. package/dist/src/kernel/packs/sparql/applyFilters.js +104 -5
  98. package/dist/src/kernel/packs/sparql/applyFilters.js.map +1 -1
  99. package/dist/src/kernel/packs/sparql/buildLookupQuery.js +306 -43
  100. package/dist/src/kernel/packs/sparql/buildLookupQuery.js.map +1 -1
  101. package/dist/src/kernel/packs/types.js.map +1 -1
  102. package/dist/src/kernel/project/cli/buildProgram.js +1 -1
  103. package/dist/src/kernel/project/cli/buildProgram.js.map +1 -1
  104. package/dist/src/kernel/project/cli/dispatch.js +23 -23
  105. package/dist/src/kernel/project/cli/dispatch.js.map +1 -1
  106. package/dist/src/kernel/project/cli/globalFlags.js +4 -1
  107. package/dist/src/kernel/project/cli/globalFlags.js.map +1 -1
  108. package/dist/src/kernel/project/cli/helpFormat.js +1 -2
  109. package/dist/src/kernel/project/cli/helpFormat.js.map +1 -1
  110. package/dist/src/kernel/project/cli/rootHelp.js +34 -4
  111. package/dist/src/kernel/project/cli/rootHelp.js.map +1 -1
  112. package/dist/src/kernel/project/mcp/registerVerb.js +16 -1
  113. package/dist/src/kernel/project/mcp/registerVerb.js.map +1 -1
  114. package/dist/src/kernel/render/renderers.js +1 -1
  115. package/dist/src/kernel/render/style.js +29 -9
  116. package/dist/src/kernel/render/style.js.map +1 -1
  117. package/dist/src/kernel/render/vocabulary.js +174 -0
  118. package/dist/src/kernel/render/vocabulary.js.map +1 -0
  119. package/dist/src/kernel/spec/emitReference.js +1 -1
  120. package/dist/src/kernel/spec/emitReference.js.map +1 -1
  121. package/package.json +16 -15
  122. package/pragma.conf.ts +241 -34
  123. package/src/bin.ts +8 -1
  124. package/src/capabilities/block.parity.test.ts +25 -11
  125. package/src/capabilities/block.shipped.exec.test.ts +282 -0
  126. package/src/capabilities/block.tierRank.exec.test.ts +300 -0
  127. package/src/capabilities/colophon/colophon.render.ts +1 -2
  128. package/src/capabilities/colophon/colophon.test.ts +2 -2
  129. package/src/capabilities/create/createGrammar.test.ts +1 -1
  130. package/src/capabilities/create/mount.ts +3 -3
  131. package/src/capabilities/distribution.parity.test.ts +4 -0
  132. package/src/capabilities/doctor/checks/checkPackageRefs.ts +69 -4
  133. package/src/capabilities/doctor/checks/checkShellCompletions.test.ts +6 -4
  134. package/src/capabilities/doctor/checks/checkShellCompletions.ts +8 -8
  135. package/src/capabilities/doctor/checks/harnessInventory.test.ts +219 -0
  136. package/src/capabilities/doctor/checks/harnessInventory.ts +298 -0
  137. package/src/capabilities/doctor/checks/index.ts +6 -6
  138. package/src/capabilities/doctor/checks/targetHealth.ts +229 -59
  139. package/src/capabilities/doctor/doctor.render.test.ts +108 -32
  140. package/src/capabilities/doctor/doctor.render.ts +56 -80
  141. package/src/capabilities/doctor/doctor.test.ts +247 -35
  142. package/src/capabilities/doctor/doctor.verb.ts +7 -2
  143. package/src/capabilities/doctor/runChecks.ts +14 -11
  144. package/src/capabilities/doctor/types.ts +15 -24
  145. package/src/capabilities/emptyRecovery.test.ts +10 -2
  146. package/src/capabilities/graph/query.render.ts +2 -2
  147. package/src/capabilities/info/collectInfo.ts +8 -1
  148. package/src/capabilities/info/info.render.ts +6 -2
  149. package/src/capabilities/info/info.test.ts +37 -1
  150. package/src/capabilities/info/types.ts +10 -2
  151. package/src/capabilities/prompt/prompt.render.ts +2 -2
  152. package/src/capabilities/renderVocabularySync.test.ts +82 -0
  153. package/src/capabilities/scopeTypeSync.test.ts +29 -15
  154. package/src/capabilities/setup/buildPlan.ts +45 -41
  155. package/src/capabilities/setup/index.ts +1 -1
  156. package/src/capabilities/setup/mode.ts +2 -2
  157. package/src/capabilities/setup/operations/index.ts +6 -1
  158. package/src/capabilities/setup/operations/setupGenerator.ts +144 -70
  159. package/src/capabilities/setup/operations/setupLsp.ts +129 -37
  160. package/src/capabilities/setup/operations/setupMcp.ts +132 -61
  161. package/src/capabilities/setup/operations/setupSkills.ts +392 -58
  162. package/src/capabilities/setup/plan.render.ts +171 -76
  163. package/src/capabilities/setup/plan.ts +17 -12
  164. package/src/capabilities/setup/setup.mcp.correctness.test.ts +9 -9
  165. package/src/capabilities/setup/setup.render.test.ts +50 -36
  166. package/src/capabilities/setup/setup.render.ts +1 -1
  167. package/src/capabilities/setup/setup.test.ts +881 -50
  168. package/src/capabilities/setup/setup.verb.ts +91 -33
  169. package/src/capabilities/setup/targets.ts +120 -52
  170. package/src/capabilities/setup/types.ts +10 -18
  171. package/src/capabilities/shared/index.ts +17 -6
  172. package/src/capabilities/shared/packageManager.test.ts +421 -6
  173. package/src/capabilities/shared/packageManager.ts +394 -59
  174. package/src/capabilities/skill/bundledSkills.test.ts +347 -0
  175. package/src/capabilities/skill/discover.ts +100 -11
  176. package/src/capabilities/skill/render.ts +2 -2
  177. package/src/capabilities/skill/skill.test.ts +17 -4
  178. package/src/capabilities/sources/installSkills.ts +181 -3
  179. package/src/capabilities/sources/runUpdate.ts +78 -2
  180. package/src/capabilities/sources/sources.test.ts +228 -0
  181. package/src/capabilities/sources/update.verb.ts +3 -3
  182. package/src/capabilities/surface.test.ts +2 -2
  183. package/src/capabilities/upgrade/runUpgrade.ts +45 -6
  184. package/src/capabilities/upgrade/types.ts +10 -2
  185. package/src/capabilities/upgrade/upgrade.render.ts +9 -2
  186. package/src/capabilities/upgrade/upgrade.test.ts +72 -0
  187. package/src/constants.ts +6 -1
  188. package/src/identity.test.ts +18 -5
  189. package/src/kernel/completion/entitySource.test.ts +15 -2
  190. package/src/kernel/completion/safety.test.ts +16 -9
  191. package/src/kernel/config/defaults.test.ts +2 -1
  192. package/src/kernel/index.ts +11 -2
  193. package/src/kernel/interactivity.test.ts +76 -0
  194. package/src/kernel/interactivity.ts +69 -0
  195. package/src/kernel/packs/compile.test.ts +92 -0
  196. package/src/kernel/packs/renderPack.ts +3 -3
  197. package/src/kernel/packs/resolveEntity.test.ts +75 -14
  198. package/src/kernel/packs/resolveEntity.ts +88 -24
  199. package/src/kernel/packs/runBodies.ts +84 -19
  200. package/src/kernel/packs/schema.ts +60 -4
  201. package/src/kernel/packs/sparql/applyFilters.ts +125 -4
  202. package/src/kernel/packs/sparql/buildLookupQuery.test.ts +290 -0
  203. package/src/kernel/packs/sparql/buildLookupQuery.ts +323 -45
  204. package/src/kernel/packs/toolDescription.test.ts +35 -1
  205. package/src/kernel/packs/types.ts +125 -2
  206. package/src/kernel/project/cli/buildProgram.test.ts +73 -2
  207. package/src/kernel/project/cli/buildProgram.ts +8 -1
  208. package/src/kernel/project/cli/dispatch.test.ts +5 -4
  209. package/src/kernel/project/cli/dispatch.ts +25 -24
  210. package/src/kernel/project/cli/globalFlags.ts +4 -1
  211. package/src/kernel/project/cli/helpFormat.ts +1 -2
  212. package/src/kernel/project/cli/rootHelp.ts +36 -3
  213. package/src/kernel/project/mcp/registerVerb.ts +20 -1
  214. package/src/kernel/render/renderers.ts +1 -1
  215. package/src/kernel/render/style.ts +32 -9
  216. package/src/kernel/render/vocabulary.ts +276 -0
  217. package/src/kernel/spec/emitReference.ts +1 -1
  218. package/src/kernel/spec/types.ts +35 -6
  219. package/src/testing/PARITY_GAPS.ts +9 -3
  220. package/src/testing/behavioral/docExamples.test.ts +4 -2
  221. package/src/testing/behavioral/errorMatrix.mcp.test.ts +110 -7
  222. package/src/testing/behavioral/journeys.firstInstall.test.ts +7 -2
  223. package/src/testing/behavioral/journeys.packageStories.test.ts +6 -3
  224. package/src/testing/eval/__snapshots__/eval.test.ts.snap +26 -1
  225. package/src/testing/eval/cases/readNouns.ts +245 -9
  226. package/src/testing/fixtures/blockGraph.ts +28 -13
  227. package/src/testing/fixtures/graph/canonical.ts +95 -12
  228. package/dist/src/capabilities/shared/bands.js +0 -16
  229. package/dist/src/capabilities/shared/bands.js.map +0 -1
  230. package/src/capabilities/shared/bands.ts +0 -16
@@ -8,17 +8,44 @@
8
8
  * the input is a free term matched the same way. A row lacking the variable never
9
9
  * matches. Several filters combine conjunctively; several values for one
10
10
  * filter (a repeated flag) combine as a union.
11
+ *
12
+ * A filter declaring `match: "set"` reads its cell as a space-separated SET and
13
+ * matches any member — the shape a query produces for a dimension a row belongs
14
+ * to several values of at once (a category and its ancestors, say). The
15
+ * comparison is otherwise identical, so exactly one code path decides what a
16
+ * match is.
17
+ *
18
+ * A value-free filter still REJECTS a value the data does not carry, with the
19
+ * admissible values as `validOptions` — the same courtesy a declared-`values`
20
+ * filter has always extended, without copying the vocabulary into the consumer.
21
+ * The vocabulary is read from the graph, because the graph IS the vocabulary; a
22
+ * story that hard-coded the slugs would go stale the first time the data grew a
23
+ * category. Before this, a typo'd `--category` returned
24
+ * `{"ok":true,"data":[],"meta":{}}` — indistinguishable, over MCP, from a
25
+ * genuinely empty category.
26
+ *
27
+ * WHICH part of the graph is the vocabulary matters, and it is NOT the rows.
28
+ * Rows are a population: a value can be perfectly real while no row carries it —
29
+ * `standard categories` lists a category with count 0, `ds:ConceptType` declares
30
+ * "Decision guide" before any concept uses it. Validating against rows called
31
+ * those `INVALID_INPUT`, when the documented answer is a calm empty list. So a
32
+ * filter DECLARES where its vocabulary lives ({@link PackFilter.vocabulary},
33
+ * resolved by the caller and handed in here), and the observed rows are the
34
+ * fallback for a filter that declares none — the only evidence there is, and
35
+ * knowingly narrower than the truth.
11
36
  */
12
37
  import { PragmaError } from "../../error/index.js";
13
38
  /**
14
39
  * @param rows - Rows produced by the pack's list query.
15
40
  * @param filters - Declared filters (absent means no filtering).
16
41
  * @param params - Story parameters as provided by the surface.
42
+ * @param vocabularies - Authoritative values per filter param, resolved from
43
+ * each filter's declared `vocabulary` (see {@link FilterVocabularies}).
17
44
  * @returns Rows matching every provided filter.
18
45
  * @throws PragmaError INVALID_INPUT when a value is not in a filter's declared
19
46
  * set, or when a value-free filter receives a non-string value.
20
47
  */
21
- export function applyPackFilters(rows, filters, params) {
48
+ export function applyPackFilters(rows, filters, params, vocabularies) {
22
49
  let result = rows;
23
50
  for (const filter of filters ?? []) {
24
51
  const provided = params[filter.param];
@@ -34,13 +61,85 @@ export function applyPackFilters(rows, filters, params) {
34
61
  const terms = occurrences.map((occurrence) => values === undefined
35
62
  ? requireStringValue(occurrence, filter).toLowerCase()
36
63
  : canonicalizeFilterValue(occurrence, filter, values).toLowerCase());
37
- result = result.filter((row) => {
38
- const cell = row[filter.variable]?.normalize("NFC").toLowerCase();
39
- return cell !== undefined && terms.includes(cell);
40
- });
64
+ // The fallback vocabulary is read from the UNFILTERED rows: a value that
65
+ // exists but is excluded by a conjunction is a legitimately empty answer,
66
+ // not a bad argument.
67
+ if (values === undefined)
68
+ rejectUnknownValue(vocabularies?.get(filter.param) ?? observedValues(rows, filter), filter, occurrences, terms);
69
+ result = result.filter((row) => cellValues(row, filter).some((value) => terms.includes(value.toLowerCase())));
41
70
  }
42
71
  return result;
43
72
  }
73
+ /**
74
+ * The values the rows themselves carry — the fallback vocabulary for a filter
75
+ * that declares no authoritative one, in the data's own DISPLAY spelling.
76
+ */
77
+ function observedValues(rows, filter) {
78
+ const observed = new Map();
79
+ for (const row of rows) {
80
+ for (const value of cellValues(row, filter)) {
81
+ const key = value.toLowerCase();
82
+ if (!observed.has(key))
83
+ observed.set(key, value);
84
+ }
85
+ }
86
+ return [...observed.values()];
87
+ }
88
+ /**
89
+ * Reject a value-free filter value the vocabulary does not admit, naming the
90
+ * ones it does.
91
+ *
92
+ * Silent when the vocabulary is EMPTY: an unbuilt or genuinely-empty store is
93
+ * not the caller's mistake, and the list's own `emptyRecovery` is the right
94
+ * voice for it.
95
+ *
96
+ * A value the vocabulary admits is never rejected here even when no row carries
97
+ * it — a real slug with zero standards is a calm empty list, which is what the
98
+ * tool descriptions document and what `standard categories` reporting count 0
99
+ * promises.
100
+ *
101
+ * @throws PragmaError INVALID_INPUT when a term matches none of the admissible
102
+ * values, carrying them as `validOptions`.
103
+ */
104
+ function rejectUnknownValue(vocabulary, filter, occurrences, terms) {
105
+ const admissible = new Map();
106
+ for (const value of vocabulary) {
107
+ const key = value.normalize("NFC").toLowerCase();
108
+ if (!admissible.has(key))
109
+ admissible.set(key, value.normalize("NFC"));
110
+ }
111
+ if (admissible.size === 0)
112
+ return;
113
+ const index = terms.findIndex((term) => !admissible.has(term));
114
+ if (index === -1)
115
+ return;
116
+ const validOptions = [...admissible.values()].sort();
117
+ throw PragmaError.invalidInput(filter.param, String(occurrences[index]), {
118
+ validOptions,
119
+ recovery: {
120
+ message: `Values allowed for --${filter.param}: ${validOptions.join(", ")}.`,
121
+ },
122
+ });
123
+ }
124
+ /**
125
+ * The values a row offers for one filter, in their DISPLAY spelling (NFC).
126
+ *
127
+ * One value for an ordinary filter; every space-separated member for a `"set"`
128
+ * one. A row lacking the variable offers none, so it never matches. Kept in the
129
+ * data's own casing because these are also what an INVALID_INPUT lists back as
130
+ * `validOptions` — lowercasing here would hand the caller a value the graph does
131
+ * not spell that way. Comparison lowercases at the point of comparison instead.
132
+ */
133
+ function cellValues(row, filter) {
134
+ const cell = row[filter.variable];
135
+ if (cell === undefined)
136
+ return [];
137
+ const normalized = cell.normalize("NFC");
138
+ if (filter.match !== "set") {
139
+ return normalized === "" ? [] : [normalized];
140
+ }
141
+ return normalized.split(/\s+/).filter((value) => value !== "");
142
+ }
44
143
  /** @throws PragmaError INVALID_INPUT when a value-free filter value is not a string. */
45
144
  function requireStringValue(provided, filter) {
46
145
  if (typeof provided !== "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"applyFilters.js","sourceRoot":"","sources":["../../../../../src/kernel/packs/sparql/applyFilters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAe,EACf,OAA0C,EAC1C,MAA+B;IAE/B,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,MAAM,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,QAAQ,KAAK,SAAS;YAAE,SAAS;QACrC,uEAAuE;QACvE,yEAAyE;QACzE,+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AC;QACjC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CACvB,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,WAAW,EAAE,CACpE,CAAC;QACF,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC7D,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC;QACzB,QAAQ,EAAE;YACR,OAAO,EAAE,wBAAwB,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;SACvE;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -5,15 +5,47 @@
5
5
  * and which properties to read; the query text is generated here so
6
6
  * user-supplied names are always escaped SPARQL string literals, and level-gated
7
7
  * fields below the active level are excluded from the projection (fetch-gating).
8
- * Matching on the `by` property is exact and case-insensitive.
8
+ * Matching on the name is exact and case-insensitive.
9
9
  *
10
- * Every name-addressed resolve is TOTALLY ORDERED before its `LIMIT 1`. A name
11
- * can recur across tiers, and an unordered `LIMIT 1` hands the tie to the
12
- * store's enumeration order — a different answer on a different machine, or
13
- * after a repack. `ORDER BY STR(?uri)` is a total, engine-independent order over
14
- * a variable that is always bound (`?uri` carries the `by` triple), so it needs
15
- * no unbound-value sentinel. It fixes WHICH answer is arbitrary, not WHETHER:
16
- * declaring a precedence between tiers is an ontology change, tracked separately.
10
+ * WHAT an entity's name IS lives in one place — {@link nameBinding} — and every
11
+ * form here uses it: the asserted `by` value, plus, for a lookup that DECLARES
12
+ * `nameFallback: "iri"`, the IRI-derived name its class constraint can vouch
13
+ * for. That single binding is what makes the population a `list` publishes and
14
+ * the population a `lookup` answers to the same population.
15
+ *
16
+ * A name-addressed resolve RANKS, and returns every row it ranked. A name can
17
+ * reach several entities (25 of the live design system's block names do), and
18
+ * the `LIMIT 1` that used to sit under the ordering discarded all but the first
19
+ * inside the STORE, where nothing downstream could see that it had happened —
20
+ * `block lookup button` answered with Launchpad's Button and gave no sign the
21
+ * global one existed, because `apps_launchpad…` sorts before `global…`.
22
+ *
23
+ * The limit is gone from the NAME forms so the resolver can see what it is
24
+ * choosing between. It still answers with one entity — the arity is the tool's
25
+ * contract — but the rows it did not take become the IRIs of its notice, which
26
+ * is the only address that reaches them. (An IRI-addressed form keeps its
27
+ * `LIMIT 1`: an IRI is one entity by construction, so there is nothing to rank
28
+ * and nothing set aside.)
29
+ *
30
+ * The losers are NOT free, and an earlier draft of this comment claimed they
31
+ * were. `lookupProjection`'s optionals sit in the same SELECT as the ranking, so
32
+ * every matching URI has its declared fields projected, and a multi-valued field
33
+ * multiplies rows per entity before `firstRowPerEntity` throws them away. On the
34
+ * live graph that is small — 25 shared names, two entities each — but it is a
35
+ * product, not a constant, and the honest shape is a two-phase resolve: rank the
36
+ * URIs in a minimal SELECT, then project fields for the ones actually answered
37
+ * with. That restructure is deliberately not done here: it is the same query the
38
+ * pending no-limit change would rewrite again, and doing it twice would land two
39
+ * migrations on one seam.
40
+ *
41
+ * The order is {@link rankingClause}'s `?score`, then `STR(?uri)`. The score
42
+ * multiplies the two things a pack may declare about which entity a bare name
43
+ * MEANS — `weights` (which KIND of thing) and `scopeWeight` (WHOSE) — and a
44
+ * story that declares neither falls through to `STR(?uri)` alone, a total,
45
+ * engine-independent order over a variable that is always bound (`?uri` carries
46
+ * the class constraint, or the `by` triple when the name is not derived), so it
47
+ * needs no unbound-value sentinel. That final key is what makes the ranking a
48
+ * TOTAL order rather than a better arbitrary one.
17
49
  */
18
50
  import { activeExpands, activeFields } from "../disclosure.js";
19
51
  import { escapeSparqlString, formatTerm } from "./escape.js";
@@ -39,6 +71,10 @@ function buildTypeConstraint(lookup) {
39
71
  * differ ONLY in how `?uri` is bound (a `FILTER` on the escaped name vs a `BIND`
40
72
  * of the resolved IRI), so both thread the active level through here and gate
41
73
  * identically — an IRI-addressed lookup honours `--detail` just like a name one.
74
+ *
75
+ * `constraint` and `optionals` are handed back SEPARATELY because the `?name`
76
+ * binding has to sit between them: it reads `?uri`, which the class constraint
77
+ * binds, and a SPARQL `BIND` may only name variables already in scope.
42
78
  */
43
79
  function lookupProjection(lookup, level) {
44
80
  const fields = activeFields(lookup, level);
@@ -48,49 +84,264 @@ function lookupProjection(lookup, level) {
48
84
  .join("\n");
49
85
  return {
50
86
  header: `SELECT ?uri ?name${vars.length > 0 ? ` ${vars}` : ""} WHERE {`,
51
- body: buildTypeConstraint(lookup) + optionals,
87
+ constraint: buildTypeConstraint(lookup).trimEnd(),
88
+ optionals,
89
+ };
90
+ }
91
+ /**
92
+ * The IRI-derived display name, in ONE spelling every relaxed form shares.
93
+ *
94
+ * The local name is everything after the last `#` or `/`, and its dot-separated
95
+ * hierarchy segments are published with slashes — `cs:react.component.props` →
96
+ * `react/component/props`. That is not an invention here: it is the derivation
97
+ * the `standard` list story already performs to PUBLISH a row's name, so this is
98
+ * the same rule read from the other side. Written once, so the name a list hands
99
+ * out and the name a lookup answers to cannot drift apart.
100
+ */
101
+ const DERIVED_NAME = 'REPLACE(REPLACE(STR(?uri), "^.*[#/]", ""), "\\\\.", "/")';
102
+ /**
103
+ * The `?name` binding shared by every lookup form.
104
+ *
105
+ * By DEFAULT the `by` triple is required, and that is the honest default: `by`
106
+ * is documented as "the property whose value names the entity", so an entity
107
+ * without one has no name, is not addressable, and is not drawn by `sample`.
108
+ * It is also the one thing standing between a typo'd IRI and an empty entity.
109
+ *
110
+ * A story whose `list` SYNTHESIZES a name instead of reading one declares
111
+ * `nameFallback: "iri"`, and then the triple becomes OPTIONAL with
112
+ * {@link DERIVED_NAME} behind it. `standard` is the case that exists: 22 of the
113
+ * 156 live code standards carry a `cs:name`, and the code-standards ontology
114
+ * says so deliberately — it is "an optional human-readable display title" that
115
+ * "never participates in identity". `standard list` published
116
+ * `react/component/tsdoc` while `standard lookup react/component/tsdoc`
117
+ * answered ENTITY_NOT_FOUND with empty suggestions, because the only
118
+ * addressable population was the ~13% carrying an asserted name.
119
+ *
120
+ * INFERRING the fallback from the mere PRESENCE of a class constraint is what
121
+ * this option replaced, and it was over-reach in both directions of the same
122
+ * defect: `token list` requires `ds:tokenId`, so an inferred fallback made a
123
+ * `ds:Token` without one addressable and sampleable under a name `token list`
124
+ * never publishes. The declaration is per story because the list/lookup
125
+ * agreement is per story.
126
+ *
127
+ * The class constraint is still required for the fallback (the schema rejects
128
+ * the pairing, and this guard keeps a statically-compiled story from generating
129
+ * a query with nothing bounding `?uri`): a derived name is only as trustworthy
130
+ * as the class vouching for the entity it came from.
131
+ *
132
+ * One binding then serves the name resolve, the miss-suggestion pool, glob
133
+ * expansion and `sample`'s draw pool alike — every form that decides WHICH
134
+ * entities a name can reach. (The IRI-addressed forms reach an entity without
135
+ * going through a name at all: see {@link iriNameBinding}.)
136
+ */
137
+ function nameBinding(lookup) {
138
+ if (!derivesNames(lookup))
139
+ return ` ?uri ${formatTerm(lookup.by)} ?name .`;
140
+ return [
141
+ ` OPTIONAL { ?uri ${formatTerm(lookup.by)} ?byName . }`,
142
+ ` BIND(COALESCE(?byName, ${DERIVED_NAME}) AS ?name)`,
143
+ ].join("\n");
144
+ }
145
+ /**
146
+ * Whether this lookup names an entity that carries no `by` value.
147
+ *
148
+ * The class constraint is part of the condition, not merely a schema rule the
149
+ * builders trust: without one there is no triple bounding `?uri`, so a derived
150
+ * name would be scanned over the whole graph. The schema rejects the pairing
151
+ * for declared packs; this keeps a statically-compiled story from generating
152
+ * that query.
153
+ */
154
+ function derivesNames(lookup) {
155
+ return (lookup.nameFallback === "iri" &&
156
+ Boolean(lookup.type ?? lookup.types?.length));
157
+ }
158
+ /**
159
+ * The `?name` binding for an IRI-ADDRESSED form.
160
+ *
161
+ * An IRI names the entity by itself, so here the `by` value is a LABEL to
162
+ * project, not the thing that identifies it — and the class constraint is
163
+ * already a sufficient existence check. So the triple is OPTIONAL wherever a
164
+ * class vouches for the entity, and `?name` is simply left unbound when there is
165
+ * no label; it is REQUIRED only for a lookup constraining no class, where it is
166
+ * the one thing standing between a typo'd IRI and an empty entity.
167
+ *
168
+ * A story that {@link derivesNames} gets the same COALESCE the name forms use,
169
+ * so an entity reached by IRI reports the name `list` published for it rather
170
+ * than a blank.
171
+ */
172
+ function iriNameBinding(lookup) {
173
+ if (derivesNames(lookup))
174
+ return nameBinding(lookup);
175
+ const named = `?uri ${formatTerm(lookup.by)} ?name .`;
176
+ const constrained = Boolean(lookup.type ?? lookup.types?.length);
177
+ return constrained ? ` OPTIONAL { ${named} }` : ` ${named}`;
178
+ }
179
+ /**
180
+ * Render a declared weight as a SPARQL numeric literal (never exponential).
181
+ *
182
+ * `toFixed` is the wrong instrument twice over, and both bite inside the 0–1
183
+ * range the schema allows. It ROUNDS — `0.1234567` became `0.123457`, silently
184
+ * altering a ranking a pack author declared — and stripping the trailing zeros
185
+ * off its output turns `0.0000001` into `0.`, which is not a numeric literal at
186
+ * all and makes the query a parse error rather than a wrong answer.
187
+ *
188
+ * `String` already prints the shortest exact round-trip, so it is the right
189
+ * source of digits; the only thing it does that SPARQL cannot read is
190
+ * exponent notation, which xsd:decimal's grammar has no form for. Expand that
191
+ * case and pass everything else through untouched.
192
+ */
193
+ function sparqlNumber(value) {
194
+ if (Number.isInteger(value))
195
+ return String(value);
196
+ const text = String(value);
197
+ const exponent = /e-(\d+)$/i.exec(text);
198
+ if (exponent === null)
199
+ return text;
200
+ // `1e-7` / `1.5e-7`: the decimal places needed are the exponent plus whatever
201
+ // the mantissa already carried, which is exact — no rounding can occur.
202
+ const mantissaPlaces = text.split("e")[0]?.split(".")[1]?.length ?? 0;
203
+ return value.toFixed(Number(exponent[1]) + mantissaPlaces);
204
+ }
205
+ /**
206
+ * `left * right`, guarded where an operand may be ZERO.
207
+ *
208
+ * Not defensiveness — a MEASURED engine defect, and the top scope hits it every
209
+ * time. oxigraph raises on an xsd:decimal times a zero (`0.2 * 0` errors, while
210
+ * `0.2 * 1` is `0.2`), and a raising expression inside a `BIND` leaves its
211
+ * variable unbound. Written the arithmetic way, the depth-0 scope — the one that
212
+ * is supposed to WIN — is the only one whose weight never binds, and what
213
+ * happens next is decided by whatever the surrounding `COALESCE` falls back to.
214
+ * The same expression on the `block list` side fell back to 0 and sorted every
215
+ * top-tier row LAST, which is how this was found. Both sides now say what they
216
+ * mean. Only VARIABLE operands are tested; a declared literal is resolved at
217
+ * build time by the callers.
218
+ */
219
+ function sparqlProduct(left, right) {
220
+ const guards = [left, right]
221
+ .filter((operand) => operand.startsWith("?"))
222
+ .map((operand) => `${operand} = 0`);
223
+ const product = `${left} * ${right}`;
224
+ return guards.length === 0
225
+ ? product
226
+ : `IF(${guards.join(" || ")}, 0, ${product})`;
227
+ }
228
+ /**
229
+ * The type factor: the LOWEST weight declared for any class the entity belongs
230
+ * to, 1 when none is.
231
+ *
232
+ * An IF-ladder over `EXISTS` rather than a weight column on the class VALUES,
233
+ * because a join would multiply rows for an entity in two weighted classes and
234
+ * the resolve now returns every row it finds. Lowest weight tested FIRST, so the
235
+ * ladder means MIN — the same rule the MCP listing's `effectiveWeight` states in
236
+ * prose: a demotion any membership asks for is not cancelled by a membership
237
+ * that asked for nothing.
238
+ */
239
+ function typeWeightBind(lookup) {
240
+ const declared = Object.entries(lookup.weights ?? {});
241
+ if (declared.length === 0)
242
+ return "";
243
+ const ladder = [...declared]
244
+ .sort(([aType, aWeight], [bType, bWeight]) => aWeight === bWeight ? aType.localeCompare(bType) : aWeight - bWeight)
245
+ .reduceRight((fallback, [type, weight]) => `IF(EXISTS { ?uri a ${formatTerm(type)} }, ${sparqlNumber(weight)}, ${fallback})`, "1");
246
+ return ` BIND(${ladder} AS ?rankType)`;
247
+ }
248
+ /**
249
+ * The scope factor: how much the entity's containing scope is worth, DERIVED
250
+ * from the depth of that scope's own path-shaped name.
251
+ *
252
+ * Nested OPTIONALs, not a flat sequence: `?rankScope` is unbound for an entity
253
+ * outside any scope, and a following top-level `OPTIONAL { ?rankScope <by> ?n }`
254
+ * would then match every such triple in the graph and multiply the row.
255
+ *
256
+ * The depth is the separator count, so nothing is enumerated and a scope the
257
+ * ontology adds tomorrow inherits its place. `COALESCE` states the retirement
258
+ * path in the query itself: an ASSERTED weight wins, the derived one answers
259
+ * until there is one, and an entity with no scope at all scores a neutral 1
260
+ * rather than dropping below entities that have one.
261
+ */
262
+ function scopeWeightBinds(lookup) {
263
+ const scope = lookup.scopeWeight;
264
+ if (!scope)
265
+ return "";
266
+ const name = "?rankScopeName";
267
+ const asserted = scope.asserted
268
+ ? [
269
+ ` OPTIONAL { ?rankScope ${formatTerm(scope.asserted)} ?rankAsserted . }`,
270
+ ]
271
+ : [];
272
+ // A falloff of 0 ranks every scope alike, so the derived weight is the
273
+ // constant — and the depth it would multiply is never computed.
274
+ const derived = scope.falloff === 0
275
+ ? "1"
276
+ : `1 - ${sparqlProduct(sparqlNumber(scope.falloff), "?rankDepth")}`;
277
+ return [
278
+ " OPTIONAL {",
279
+ ` ?uri ${formatTerm(scope.via)} ?rankScope .`,
280
+ ` OPTIONAL { ?rankScope ${formatTerm(scope.by)} ${name} . }`,
281
+ ...asserted,
282
+ " }",
283
+ ` BIND(STRLEN(${name}) - STRLEN(REPLACE(${name}, "/", "")) AS ?rankDepth)`,
284
+ ` BIND(${derived} AS ?rankDerived)`,
285
+ // Floored at 0: a scope deep enough to drive the factor negative would
286
+ // otherwise INVERT the type factor it multiplies, promoting a part of a
287
+ // block above a whole one.
288
+ ` BIND(COALESCE(${scope.asserted ? "?rankAsserted, " : ""}IF(?rankDerived < 0, 0, ?rankDerived), 1) AS ?rankScopeWeight)`,
289
+ ].join("\n");
290
+ }
291
+ /**
292
+ * The `?score` a name resolve orders by, and the ORDER BY that reads it.
293
+ *
294
+ * The two factors MULTIPLY rather than tiebreak, and that is the editorial
295
+ * ruling, not an implementation convenience: neither question subsumes the
296
+ * other. A whole component in a nested scope (1 × 0.8) outranks a mere PART of a
297
+ * block in the widest one (0.6 × 1), while two components of equal kind are
298
+ * separated by their scopes alone (1 × 1 beats 1 × 0.8). Both live cases fall
299
+ * out of one product.
300
+ *
301
+ * @returns The BIND lines to splice into the WHERE clause, and the ORDER BY
302
+ * line — a story declaring neither factor gets no BINDs and `STR(?uri)` alone.
303
+ */
304
+ function rankingClause(lookup) {
305
+ const factors = [typeWeightBind(lookup), scopeWeightBinds(lookup)].filter((line) => line !== "");
306
+ if (factors.length === 0)
307
+ return { binds: "", orderBy: "ORDER BY STR(?uri)" };
308
+ const terms = [
309
+ lookup.weights && Object.keys(lookup.weights).length > 0 ? "?rankType" : "",
310
+ lookup.scopeWeight ? "?rankScopeWeight" : "",
311
+ ].filter((term) => term !== "");
312
+ return {
313
+ binds: [
314
+ ...factors,
315
+ ` BIND(${terms.length === 2 ? sparqlProduct(terms[0], terms[1]) : terms.join("")} AS ?score)`,
316
+ ].join("\n"),
317
+ orderBy: "ORDER BY DESC(?score) STR(?uri)",
52
318
  };
53
319
  }
54
320
  /**
55
- * Build the SELECT retrieving one named entity with its declared fields.
321
+ * Build the SELECT retrieving the entities a name reaches, with their declared
322
+ * fields, best first. The caller answers with the first and names the rest.
56
323
  *
57
324
  * @param lookup - The pack's lookup declaration.
58
325
  * @param name - User-supplied entity name (escaped here).
59
326
  * @param level - Active canonical level; gated fields below it are excluded.
60
- * @returns SPARQL SELECT text.
327
+ * @returns SPARQL SELECT text, ranked and unlimited.
61
328
  */
62
329
  export function buildLookupQuery(lookup, name, level) {
63
- const { header, body } = lookupProjection(lookup, level);
330
+ const { header, constraint, optionals } = lookupProjection(lookup, level);
331
+ const ranking = rankingClause(lookup);
64
332
  return [
65
333
  header,
66
- ` ?uri ${formatTerm(lookup.by)} ?name .`,
67
- body,
334
+ constraint,
335
+ nameBinding(lookup),
336
+ ranking.binds,
337
+ optionals,
68
338
  ` FILTER (LCASE(STR(?name)) = LCASE("${escapeSparqlString(name)}"))`,
69
339
  "}",
70
- "ORDER BY STR(?uri)",
71
- "LIMIT 1",
340
+ ranking.orderBy,
72
341
  ]
73
342
  .filter((line) => line !== "")
74
343
  .join("\n");
75
344
  }
76
- /**
77
- * The `?name` clause for an IRI-addressed form.
78
- *
79
- * An IRI names the entity by itself, so the `by` value is a LABEL to project,
80
- * not the thing that identifies it — and a class constraint is already a
81
- * sufficient existence check. Requiring the `by` triple here made every entity
82
- * that carries no name unaddressable by any means at all: 131 of the 144 live
83
- * code standards have no `cs:name` (their displayed name is synthesized from the
84
- * IRI by the list story), and shell completion offers their IRIs. So the triple
85
- * is OPTIONAL wherever a class constraint can vouch for the entity, and
86
- * REQUIRED only for a lookup that declares no `type`/`types` — where it is the
87
- * one thing standing between a typo'd IRI and an empty entity.
88
- */
89
- function iriNameClause(lookup) {
90
- const named = `?uri ${formatTerm(lookup.by)} ?name .`;
91
- const constrained = Boolean(lookup.type ?? lookup.types?.length);
92
- return constrained ? ` OPTIONAL { ${named} }` : ` ${named}`;
93
- }
94
345
  /**
95
346
  * Build the SELECT retrieving one entity addressed directly by IRI.
96
347
  *
@@ -105,12 +356,13 @@ function iriNameClause(lookup) {
105
356
  * @param level - Active canonical level; gated fields below it are excluded.
106
357
  */
107
358
  export function buildLookupByIriQuery(lookup, iri, level) {
108
- const { header, body } = lookupProjection(lookup, level);
359
+ const { header, constraint, optionals } = lookupProjection(lookup, level);
109
360
  return [
110
361
  header,
111
362
  ` BIND(<${iri}> AS ?uri)`,
112
- iriNameClause(lookup),
113
- body,
363
+ constraint,
364
+ iriNameBinding(lookup),
365
+ optionals,
114
366
  "}",
115
367
  "LIMIT 1",
116
368
  ]
@@ -120,18 +372,25 @@ export function buildLookupByIriQuery(lookup, iri, level) {
120
372
  /**
121
373
  * Build the minimal name→URI resolve for a graphql-sourced lookup (and the
122
374
  * shared entry point for the sparql path's name form): maps the user-supplied
123
- * name to the entity IRI, everything else comes from the field fetch. The name
375
+ * name to the entity IRIs, everything else comes from the field fetch. The name
124
376
  * is an escaped literal; all terms are validated pack terms.
377
+ *
378
+ * Ranked and unlimited, exactly like {@link buildLookupQuery} — the two paths
379
+ * differ in where the VALUES come from, never in which entities a name reaches.
380
+ * `?score` is deliberately NOT projected: it orders the rows and is none of the
381
+ * caller's business, and projecting it would leak a ranking artefact into
382
+ * `--format json`.
125
383
  */
126
384
  export function buildNameResolveQuery(lookup, name) {
385
+ const ranking = rankingClause(lookup);
127
386
  return [
128
387
  "SELECT ?uri ?name WHERE {",
129
- ` ?uri ${formatTerm(lookup.by)} ?name .`,
130
388
  buildTypeConstraint(lookup).trimEnd(),
389
+ nameBinding(lookup),
390
+ ranking.binds,
131
391
  ` FILTER (LCASE(STR(?name)) = LCASE("${escapeSparqlString(name)}"))`,
132
392
  "}",
133
- "ORDER BY STR(?uri)",
134
- "LIMIT 1",
393
+ ranking.orderBy,
135
394
  ]
136
395
  .filter((line) => line !== "")
137
396
  .join("\n");
@@ -149,8 +408,8 @@ export function buildIriResolveQuery(lookup, iri) {
149
408
  return [
150
409
  "SELECT ?uri ?name WHERE {",
151
410
  ` BIND(<${iri}> AS ?uri)`,
152
- iriNameClause(lookup),
153
411
  buildTypeConstraint(lookup).trimEnd(),
412
+ iriNameBinding(lookup),
154
413
  "}",
155
414
  "LIMIT 1",
156
415
  ]
@@ -205,8 +464,12 @@ export function buildLookupNamesQuery(lookup) {
205
464
  // `block lookup 'Butt*'` listed one Button twice while the other Button
206
465
  // never appeared at all.
207
466
  "SELECT DISTINCT ?name WHERE {",
208
- ` ?uri ${formatTerm(lookup.by)} ?name .`,
209
467
  buildTypeConstraint(lookup).trimEnd(),
468
+ // Same {@link nameBinding} the resolves use, so the addressable population
469
+ // and the resolvable population are the same population. When they were
470
+ // not, a name a miss-suggestion offered could itself miss, and a glob
471
+ // expanded over a pool the resolve could not answer from.
472
+ nameBinding(lookup),
210
473
  "}",
211
474
  ]
212
475
  .filter((line) => line !== "")
@@ -1 +1 @@
1
- {"version":3,"file":"buildLookupQuery.js","sourceRoot":"","sources":["../../../../../src/kernel/packs/sparql/buildLookupQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,MAAkB;IAC7C,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,YAAY,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACnD,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;IACpE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,gBAAgB,CACvB,MAAkB,EAClB,KAAyB;IAEzB,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,MAAM;SACrB,GAAG,CACF,CAAC,KAAK,EAAE,EAAE,CACR,qBAAqB,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,CAAC,IAAI,MAAM,CACvE;SACA,IAAI,CAAC,IAAI,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,0DAA0D;QAC1D,WAAW,CAAC,MAAM,CAAC;QACnB,GAAG;KACJ;SACE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;SAC7B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAGD,gFAAgF;AAChF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/kernel/packs/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAqEH,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAC5B,KAAuB;IAEvB,OAAO,UAAU,IAAI,KAAK,CAAC;AAC7B,CAAC;AA+RD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAe,EAAE,CAAC,CAAC;IACjE,KAAK;IACL,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/kernel/packs/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAqEH,4EAA4E;AAC5E,MAAM,UAAU,cAAc,CAC5B,KAAuB;IAEvB,OAAO,UAAU,IAAI,KAAK,CAAC;AAC7B,CAAC;AA0ZD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAe,EAAE,CAAC,CAAC;IACjE,KAAK;IACL,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC"}
@@ -225,7 +225,7 @@ export function buildProgram(verbs, options) {
225
225
  program.helpOption("--help", "Show help (works on any command)");
226
226
  program.enablePositionalOptions();
227
227
  program.exitOverride();
228
- useDesignedHelp(program, () => formatRootHelp(programName, description, live, version, issuesUrl));
228
+ useDesignedHelp(program, () => formatRootHelp(programName, description, live, version, issuesUrl, options.globalFlags));
229
229
  const groups = new Map();
230
230
  for (const verb of live) {
231
231
  const noun = verb.path[0];