@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.
@@ -2117,7 +2117,8 @@ export declare class Materializer implements MaterializerInterface {
2117
2117
  * Reads one guide's claims and reports parser refusals with its owner and source.
2118
2118
  *
2119
2119
  * @param source - The source label or path to name in a refusal.
2120
- * @throws Thrown with TARGET when the module or the guide parser refuses the reading.
2120
+ * @throws Thrown with TARGET when the module is unusable or the guide parser refuses the guide
2121
+ * with an error its `isGuideError` guard accepts; every other parser error propagates unchanged.
2121
2122
  * @example
2122
2123
  * ```ts
2123
2124
  * import { readSurfaceGuide } from '@orkestrel/scaffold/server'
@@ -2441,6 +2442,10 @@ export declare class Materializer implements MaterializerInterface {
2441
2442
  readonly code: string;
2442
2443
  readonly source: string;
2443
2444
  }>;
2445
+ readonly isGuideError: (value: unknown) => value is Error & {
2446
+ readonly code: string;
2447
+ readonly message: string;
2448
+ };
2444
2449
  }
2445
2450
 
2446
2451
  /**
@@ -2117,7 +2117,8 @@ export declare class Materializer implements MaterializerInterface {
2117
2117
  * Reads one guide's claims and reports parser refusals with its owner and source.
2118
2118
  *
2119
2119
  * @param source - The source label or path to name in a refusal.
2120
- * @throws Thrown with TARGET when the module or the guide parser refuses the reading.
2120
+ * @throws Thrown with TARGET when the module is unusable or the guide parser refuses the guide
2121
+ * with an error its `isGuideError` guard accepts; every other parser error propagates unchanged.
2121
2122
  * @example
2122
2123
  * ```ts
2123
2124
  * import { readSurfaceGuide } from '@orkestrel/scaffold/server'
@@ -2441,6 +2442,10 @@ export declare class Materializer implements MaterializerInterface {
2441
2442
  readonly code: string;
2442
2443
  readonly source: string;
2443
2444
  }>;
2445
+ readonly isGuideError: (value: unknown) => value is Error & {
2446
+ readonly code: string;
2447
+ readonly message: string;
2448
+ };
2444
2449
  }
2445
2450
 
2446
2451
  /**
@@ -1757,14 +1757,15 @@ function resolveHostRoot() {
1757
1757
  */
1758
1758
  function readSurfaceModule(loader = createRequire(import.meta.url)) {
1759
1759
  const loaded = attempt(() => loader("@orkestrel/guide"));
1760
- if (!loaded.success || !isSurfaceModule(loaded.value)) throw new 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 } : {} });
1760
+ if (!loaded.success || !isSurfaceModule(loaded.value)) throw new 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 } : {} });
1761
1761
  return loaded.value;
1762
1762
  }
1763
1763
  /**
1764
1764
  * Reads one guide's claims and reports parser refusals with its owner and source.
1765
1765
  *
1766
1766
  * @param source - The source label or path to name in a refusal.
1767
- * @throws Thrown with TARGET when the module or the guide parser refuses the reading.
1767
+ * @throws Thrown with TARGET when the module is unusable or the guide parser refuses the guide
1768
+ * with an error its `isGuideError` guard accepts; every other parser error propagates unchanged.
1768
1769
  * @example
1769
1770
  * ```ts
1770
1771
  * import { readSurfaceGuide } from '@orkestrel/scaffold/server'
@@ -1774,14 +1775,16 @@ function readSurfaceModule(loader = createRequire(import.meta.url)) {
1774
1775
  function readSurfaceGuide(text, owner, source, loader) {
1775
1776
  const guide = readSurfaceModule(loader);
1776
1777
  const parsed = attempt(() => guide.createGuide(text).surface().map(({ name }) => name));
1777
- if (!parsed.success) throw new ScaffoldError("TARGET", `Surface guide for ${JSON.stringify(owner.slice(0, 512))} from ${JSON.stringify(source.slice(0, 512))} was refused: ${isError(parsed.error) ? parsed.error.message : String(parsed.error)}`, {
1778
- owner,
1779
- source
1780
- });
1781
- return {
1778
+ if (parsed.success) return {
1782
1779
  owner,
1783
1780
  names: parsed.value
1784
1781
  };
1782
+ if (!guide.isGuideError(parsed.error)) throw parsed.error;
1783
+ throw new ScaffoldError("TARGET", `Surface guide for ${JSON.stringify(owner.slice(0, 512))} from ${JSON.stringify(source.slice(0, 512))} was refused: ${parsed.error.message}`, {
1784
+ owner,
1785
+ source,
1786
+ code: parsed.error.code
1787
+ });
1785
1788
  }
1786
1789
  /**
1787
1790
  * Reads each immediate package guide's bare names under its file owner.
@@ -2175,7 +2178,7 @@ function matchesPrecondition(precondition) {
2175
2178
  * ```
2176
2179
  */
2177
2180
  function isSurfaceModule(value) {
2178
- return holds(() => isObject(value) && "createGuide" in value && isFunction(value.createGuide) && "createSource" in value && isFunction(value.createSource) && "extractSourceLines" in value && isFunction(value.extractSourceLines));
2181
+ return holds(() => isObject(value) && "createGuide" in value && isFunction(value.createGuide) && "createSource" in value && isFunction(value.createSource) && "extractSourceLines" in value && isFunction(value.extractSourceLines) && "isGuideError" in value && isFunction(value.isGuideError));
2179
2182
  }
2180
2183
  /**
2181
2184
  * Narrows a value to a path naming a location on this host.