@orkestrel/scaffold 0.0.116 → 0.0.118

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,31 +1758,35 @@ 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'
1772
- * readSurfaceGuide('# Sample', 'sample', 'live guides/sample.md') // { owner: 'sample', names: [] }
1773
+ * readSurfaceGuide('# Sample', 'sample', 'live guides/sample.md') // { owner: 'sample', names: [], signatures: new Map() }
1773
1774
  * ```
1774
1775
  */
1775
1776
  function readSurfaceGuide(text, owner, source, loader) {
1776
1777
  const guide = readSurfaceModule(loader);
1777
- 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)}`, {
1778
+ const parsed = (0, _orkestrel_contract.attempt)(() => guide.createGuide(text).surface());
1779
+ if (parsed.success) return {
1779
1780
  owner,
1780
- source
1781
- });
1782
- return {
1783
- owner,
1784
- names: parsed.value
1781
+ names: parsed.value.map(({ name }) => name),
1782
+ signatures: new Map(parsed.value.flatMap(({ name, signature }) => (0, _orkestrel_contract.isString)(signature) ? [[name, signature]] : []))
1785
1783
  };
1784
+ if (!guide.isGuideError(parsed.error)) throw parsed.error;
1785
+ 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}`, {
1786
+ owner,
1787
+ source,
1788
+ code: parsed.error.code
1789
+ });
1786
1790
  }
1787
1791
  /**
1788
1792
  * Reads each immediate package guide's bare names under its file owner.
@@ -1864,6 +1868,7 @@ function readSurfaceCandidate(root, loader) {
1864
1868
  return {
1865
1869
  owner,
1866
1870
  names: [.../* @__PURE__ */ new Set([...guide?.names ?? [], ...Object.values(exports).flat()])].sort(),
1871
+ signatures: guide?.signatures ?? /* @__PURE__ */ new Map(),
1867
1872
  conflicts: (0, _src_core.collectSurfaceConflicts)(owner, exports)
1868
1873
  };
1869
1874
  }
@@ -2176,7 +2181,7 @@ function matchesPrecondition(precondition) {
2176
2181
  * ```
2177
2182
  */
2178
2183
  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));
2184
+ 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
2185
  }
2181
2186
  /**
2182
2187
  * Narrows a value to a path naming a location on this host.