@orkestrel/scaffold 0.0.116 → 0.0.117

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.
@@ -1758,14 +1758,15 @@ function resolveHostRoot() {
1758
1758
  */
1759
1759
  function readSurfaceModule(loader = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)) {
1760
1760
  const loaded = (0, _orkestrel_contract.attempt)(() => loader("@orkestrel/guide"));
1761
- if (!loaded.success || !isSurfaceModule(loaded.value)) throw new _src_core.ScaffoldError("TARGET", "Surface reflection requires @orkestrel/guide with createGuide, createSource, and extractSourceLines. Supply that module in scaffold's resolution path.", { ...!loaded.success ? { error: loaded.error } : {} });
1761
+ if (!loaded.success || !isSurfaceModule(loaded.value)) throw new _src_core.ScaffoldError("TARGET", "Surface reflection requires @orkestrel/guide with createGuide, createSource, extractSourceLines, and isGuideError. Supply that module in scaffold's resolution path.", { ...!loaded.success ? { error: loaded.error } : {} });
1762
1762
  return loaded.value;
1763
1763
  }
1764
1764
  /**
1765
1765
  * Reads one guide's claims and reports parser refusals with its owner and source.
1766
1766
  *
1767
1767
  * @param source - The source label or path to name in a refusal.
1768
- * @throws Thrown with TARGET when the module or the guide parser refuses the reading.
1768
+ * @throws Thrown with TARGET when the module is unusable or the guide parser refuses the guide
1769
+ * with an error its `isGuideError` guard accepts; every other parser error propagates unchanged.
1769
1770
  * @example
1770
1771
  * ```ts
1771
1772
  * import { readSurfaceGuide } from '@orkestrel/scaffold/server'
@@ -1775,14 +1776,16 @@ function readSurfaceModule(loader = (0, node_module.createRequire)(require("url"
1775
1776
  function readSurfaceGuide(text, owner, source, loader) {
1776
1777
  const guide = readSurfaceModule(loader);
1777
1778
  const parsed = (0, _orkestrel_contract.attempt)(() => guide.createGuide(text).surface().map(({ name }) => name));
1778
- if (!parsed.success) throw new _src_core.ScaffoldError("TARGET", `Surface guide for ${JSON.stringify(owner.slice(0, 512))} from ${JSON.stringify(source.slice(0, 512))} was refused: ${(0, _orkestrel_contract.isError)(parsed.error) ? parsed.error.message : String(parsed.error)}`, {
1779
- owner,
1780
- source
1781
- });
1782
- return {
1779
+ if (parsed.success) return {
1783
1780
  owner,
1784
1781
  names: parsed.value
1785
1782
  };
1783
+ if (!guide.isGuideError(parsed.error)) throw parsed.error;
1784
+ throw new _src_core.ScaffoldError("TARGET", `Surface guide for ${JSON.stringify(owner.slice(0, 512))} from ${JSON.stringify(source.slice(0, 512))} was refused: ${parsed.error.message}`, {
1785
+ owner,
1786
+ source,
1787
+ code: parsed.error.code
1788
+ });
1786
1789
  }
1787
1790
  /**
1788
1791
  * Reads each immediate package guide's bare names under its file owner.
@@ -2176,7 +2179,7 @@ function matchesPrecondition(precondition) {
2176
2179
  * ```
2177
2180
  */
2178
2181
  function isSurfaceModule(value) {
2179
- return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isObject)(value) && "createGuide" in value && (0, _orkestrel_contract.isFunction)(value.createGuide) && "createSource" in value && (0, _orkestrel_contract.isFunction)(value.createSource) && "extractSourceLines" in value && (0, _orkestrel_contract.isFunction)(value.extractSourceLines));
2182
+ return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isObject)(value) && "createGuide" in value && (0, _orkestrel_contract.isFunction)(value.createGuide) && "createSource" in value && (0, _orkestrel_contract.isFunction)(value.createSource) && "extractSourceLines" in value && (0, _orkestrel_contract.isFunction)(value.extractSourceLines) && "isGuideError" in value && (0, _orkestrel_contract.isFunction)(value.isGuideError));
2180
2183
  }
2181
2184
  /**
2182
2185
  * Narrows a value to a path naming a location on this host.