@orkestrel/guide 0.0.10 → 0.0.12

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.
package/README.md CHANGED
@@ -160,7 +160,7 @@ declaration.
160
160
  ## Guide
161
161
 
162
162
  For the full surface — the guide anatomy, the manifest format, and the check
163
- catalog — see [`guides/src/guide.md`](guides/src/guide.md). For the design
163
+ catalog — see [`guides/guide.md`](guides/guide.md). For the design
164
164
  and guide index, see [`guides/`](./guides/).
165
165
 
166
166
  ## Package
@@ -30,6 +30,75 @@ var EXTERNAL_SCHEMES = Object.freeze([
30
30
  "tel:"
31
31
  ]);
32
32
  //#endregion
33
+ //#region src/core/validators.ts
34
+ /**
35
+ * Whether `value` is one of the five documented {@link ExportKind} literals — the
36
+ * guard behind extracting a Surface table's `Kind` cell into a typed symbol.
37
+ *
38
+ * @param value - The candidate value
39
+ * @returns `true` when `value` is a valid {@link ExportKind}
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * isExportKind('class') // true
44
+ * isExportKind('enum') // false
45
+ * ```
46
+ */
47
+ var isExportKind = (0, _orkestrel_contract.literalOf)("type", "interface", "const", "function", "class");
48
+ /**
49
+ * Whether `value` is a well-formed {@link SurfaceSymbol} — a `name` string
50
+ * paired with a valid {@link ExportKind}.
51
+ *
52
+ * @param value - The value to test
53
+ * @returns `true` when `value` is a well-formed {@link SurfaceSymbol}
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * isSurfaceSymbol({ name: 'Markdown', kind: 'class' }) // true
58
+ * isSurfaceSymbol({ name: 'Markdown', kind: 'enum' }) // false
59
+ * ```
60
+ */
61
+ var isSurfaceSymbol = (0, _orkestrel_contract.recordOf)({
62
+ name: _orkestrel_contract.isString,
63
+ kind: isExportKind
64
+ });
65
+ /**
66
+ * Whether `value` is a well-formed {@link MethodGroup} — a backticked
67
+ * `interface` name paired with its documented `methods`.
68
+ *
69
+ * @param value - The value to test
70
+ * @returns `true` when `value` is a well-formed {@link MethodGroup}
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * isMethodGroup({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
75
+ * isMethodGroup({ interface: 'MarkdownInterface', methods: [1] }) // false
76
+ * ```
77
+ */
78
+ var isMethodGroup = (0, _orkestrel_contract.recordOf)({
79
+ interface: _orkestrel_contract.isString,
80
+ methods: (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)
81
+ });
82
+ /**
83
+ * Whether `value` is a well-formed {@link ManifestEntry} — a `## By concept`
84
+ * manifest row, its `source` accepting either a single directory or several.
85
+ *
86
+ * @param value - The value to test
87
+ * @returns `true` when `value` is a well-formed {@link ManifestEntry}
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * isManifestEntry({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
92
+ * isManifestEntry({ concept: 1 }) // false
93
+ * ```
94
+ */
95
+ var isManifestEntry = (0, _orkestrel_contract.recordOf)({
96
+ concept: _orkestrel_contract.isString,
97
+ spec: _orkestrel_contract.isString,
98
+ source: (0, _orkestrel_contract.unionOf)(_orkestrel_contract.isString, (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)),
99
+ tests: _orkestrel_contract.isString
100
+ });
101
+ //#endregion
33
102
  //#region src/core/helpers.ts
34
103
  /**
35
104
  * Extract aligned physical source-line records in one character traversal.
@@ -563,6 +632,23 @@ function normalizeDirectories(module) {
563
632
  return directories;
564
633
  }
565
634
  /**
635
+ * The stable cache key for a {@link GuideModule}. Directories normalize before
636
+ * joining, so equivalent module spellings share one key. The NUL separator
637
+ * cannot occur in filesystem-backed canonical-segment inventory keys, so no
638
+ * directory boundary can collide with directory text.
639
+ *
640
+ * @param module - The module scope to key
641
+ * @returns The normalized directories joined by NUL
642
+ *
643
+ * @example
644
+ * ```ts
645
+ * moduleKey(['src/core', 'src/browser']) // 'src/core\0src/browser'
646
+ * ```
647
+ */
648
+ function moduleKey(module) {
649
+ return normalizeDirectories(module).join("\0");
650
+ }
651
+ /**
566
652
  * The exact opaque file-inventory keys belonging under any canonical
567
653
  * {@link GuideModule} directory, sorted. `'.'` selects canonical root-relative
568
654
  * keys without accepting `/`, `./`, or `../` aliases. Every selected exact
@@ -623,6 +709,24 @@ function findMissing(names, source) {
623
709
  return names.filter((name) => !existing.has(name));
624
710
  }
625
711
  /**
712
+ * The fences whose language is absent from the caller's listed languages.
713
+ * Untagged fences are always returned because they have no language to list.
714
+ *
715
+ * @param fences - The guide fences to check
716
+ * @param languages - The listed language tags
717
+ * @returns The unlisted fences in input order
718
+ *
719
+ * @example
720
+ * ```ts
721
+ * findUnlisted([{ language: 'typescript', code: 'walk()' }], ['ts'])
722
+ * // [{ language: 'typescript', code: 'walk()' }]
723
+ * ```
724
+ */
725
+ function findUnlisted(fences, languages) {
726
+ const listed = new Set(languages);
727
+ return fences.filter((fence) => fence.language === void 0 || !listed.has(fence.language));
728
+ }
729
+ /**
626
730
  * The symbol-key set-difference between two symbol lists — `symbols` present but
627
731
  * absent from `source`, compared by {@link symbolKey} so a symbol can drift in
628
732
  * neither name nor kind.
@@ -845,77 +949,6 @@ function kindIndex(table) {
845
949
  }).trim() === "Kind") return index;
846
950
  }
847
951
  }
848
- //#endregion
849
- //#region src/core/validators.ts
850
- /**
851
- * Whether `value` is one of the five documented {@link ExportKind} literals — the
852
- * guard behind extracting a Surface table's `Kind` cell into a typed symbol.
853
- *
854
- * @param value - The candidate value
855
- * @returns `true` when `value` is a valid {@link ExportKind}
856
- *
857
- * @example
858
- * ```ts
859
- * isExportKind('class') // true
860
- * isExportKind('enum') // false
861
- * ```
862
- */
863
- var isExportKind = (0, _orkestrel_contract.literalOf)("type", "interface", "const", "function", "class");
864
- /**
865
- * Whether `value` is a well-formed {@link SurfaceSymbol} — a `name` string
866
- * paired with a valid {@link ExportKind}.
867
- *
868
- * @param value - The value to test
869
- * @returns `true` when `value` is a well-formed {@link SurfaceSymbol}
870
- *
871
- * @example
872
- * ```ts
873
- * isSurfaceSymbol({ name: 'Markdown', kind: 'class' }) // true
874
- * isSurfaceSymbol({ name: 'Markdown', kind: 'enum' }) // false
875
- * ```
876
- */
877
- var isSurfaceSymbol = (0, _orkestrel_contract.recordOf)({
878
- name: _orkestrel_contract.isString,
879
- kind: isExportKind
880
- });
881
- /**
882
- * Whether `value` is a well-formed {@link MethodGroup} — a backticked
883
- * `interface` name paired with its documented `methods`.
884
- *
885
- * @param value - The value to test
886
- * @returns `true` when `value` is a well-formed {@link MethodGroup}
887
- *
888
- * @example
889
- * ```ts
890
- * isMethodGroup({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
891
- * isMethodGroup({ interface: 'MarkdownInterface', methods: [1] }) // false
892
- * ```
893
- */
894
- var isMethodGroup = (0, _orkestrel_contract.recordOf)({
895
- interface: _orkestrel_contract.isString,
896
- methods: (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)
897
- });
898
- /**
899
- * Whether `value` is a well-formed {@link ManifestEntry} — a `## By concept`
900
- * manifest row, its `source` accepting either a single directory or several.
901
- *
902
- * @param value - The value to test
903
- * @returns `true` when `value` is a well-formed {@link ManifestEntry}
904
- *
905
- * @example
906
- * ```ts
907
- * isManifestEntry({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
908
- * isManifestEntry({ concept: 1 }) // false
909
- * ```
910
- */
911
- var isManifestEntry = (0, _orkestrel_contract.recordOf)({
912
- concept: _orkestrel_contract.isString,
913
- spec: _orkestrel_contract.isString,
914
- source: (0, _orkestrel_contract.unionOf)(_orkestrel_contract.isString, (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)),
915
- tests: _orkestrel_contract.isString
916
- });
917
- //#endregion
918
- //#region src/core/parsers.ts
919
952
  /**
920
953
  * The module-scope exports declared in one file's source text — matches
921
954
  * `export (async)? (function(\*)?|class|const|interface|type) Name`, deduped
@@ -1373,22 +1406,27 @@ function exampleMethods(lines) {
1373
1406
  return Array.from(new Set(methods)).sort();
1374
1407
  }
1375
1408
  /**
1376
- * Every ```ts fenced code block's body text anywhere in the guide document —
1377
- * a full AST walk so a fence nested inside a blockquote or list still counts.
1409
+ * Every fenced code block anywhere in the guide document. A full AST walk
1410
+ * includes fences nested inside blockquotes and lists.
1378
1411
  *
1379
1412
  * @param document - The parsed guide document
1380
- * @returns Every `ts`-lang fence's verbatim code, in walk order
1413
+ * @returns Every fence's language and verbatim code, in document order
1381
1414
  *
1382
1415
  * @example
1383
1416
  * ```ts
1384
- * extractPatterns(document) // ["import { X } from './x.js'\nX()"]
1417
+ * extractFences(document) // [{ language: 'ts', code: "import { X } from './x.js'\nX()" }]
1385
1418
  * ```
1386
1419
  */
1387
- function extractPatterns(document) {
1388
- const patterns = [];
1389
- for (const node of (0, _orkestrel_markdown.walkNodes)(document)) if ((0, _orkestrel_markdown.isCodeBlockNode)(node) && node.lang === "ts") patterns.push(node.code);
1390
- return patterns;
1420
+ function extractFences(document) {
1421
+ const fences = [];
1422
+ for (const node of (0, _orkestrel_markdown.walkNodes)(document)) if ((0, _orkestrel_markdown.isCodeBlockNode)(node)) fences.push({
1423
+ language: node.lang,
1424
+ code: node.code
1425
+ });
1426
+ return fences;
1391
1427
  }
1428
+ //#endregion
1429
+ //#region src/core/parsers.ts
1392
1430
  /**
1393
1431
  * Parse a `## By concept` manifest table into its {@link ManifestEntry} rows —
1394
1432
  * each row's Concept cell (flattened text), Spec / Tests cells (a single link
@@ -1506,7 +1544,7 @@ var manifestEntryShape = (0, _orkestrel_contract.objectShape)({
1506
1544
  /**
1507
1545
  * A stateful, structured view over one parsed guide — the six documented
1508
1546
  * projections (`sections` / `surface` / `methods` / `links` / `tests` /
1509
- * `patterns`) are extracted once at construction and cached.
1547
+ * `fences`) are extracted once at construction and cached.
1510
1548
  *
1511
1549
  * @remarks
1512
1550
  * Pure: parses `source` once via `@orkestrel/markdown` and never touches the
@@ -1528,7 +1566,7 @@ var Guide = class {
1528
1566
  #methods;
1529
1567
  #links;
1530
1568
  #tests;
1531
- #patterns;
1569
+ #fences;
1532
1570
  constructor(source) {
1533
1571
  const document = (0, _orkestrel_markdown.createMarkdown)(source).document;
1534
1572
  this.#sections = document.children.filter(_orkestrel_markdown.isHeadingNode).filter((heading) => heading.level === 2).map((heading) => (0, _orkestrel_markdown.flattenText)(heading).trim());
@@ -1536,7 +1574,7 @@ var Guide = class {
1536
1574
  this.#methods = extractMethods(document);
1537
1575
  this.#links = extractLinks(document);
1538
1576
  this.#tests = extractTests(document);
1539
- this.#patterns = extractPatterns(document);
1577
+ this.#fences = extractFences(document);
1540
1578
  }
1541
1579
  sections() {
1542
1580
  return this.#sections;
@@ -1553,12 +1591,12 @@ var Guide = class {
1553
1591
  tests() {
1554
1592
  return this.#tests;
1555
1593
  }
1556
- patterns() {
1557
- return this.#patterns;
1594
+ fences() {
1595
+ return this.#fences;
1558
1596
  }
1559
1597
  };
1560
1598
  //#endregion
1561
- //#region src/core/Source.ts
1599
+ //#region src/core/sources/Source.ts
1562
1600
  /**
1563
1601
  * A pure `SourceInterface` — reflects a module scope's intentional direct
1564
1602
  * declarations, conventional barrel-reachable surface, and member methods over
@@ -1717,11 +1755,52 @@ var Source = class {
1717
1755
  }
1718
1756
  };
1719
1757
  //#endregion
1758
+ //#region src/core/sources/SourceManager.ts
1759
+ /**
1760
+ * Resolves a consumer-owned import-specifier policy into pure source views and
1761
+ * caches those views by module, so aliases for one module share one entity.
1762
+ * Unmapped specifiers remain foreign to the consumer and return `undefined`.
1763
+ *
1764
+ * @example
1765
+ * ```ts
1766
+ * import { SourceManager } from '@orkestrel/guide'
1767
+ *
1768
+ * const sources = new SourceManager({
1769
+ * files: { 'src/core/index.ts': "export * from './types.js'" },
1770
+ * modules: { '@scope/package': 'src/core' },
1771
+ * })
1772
+ * sources.source('@scope/package')?.surface()
1773
+ * ```
1774
+ */
1775
+ var SourceManager = class {
1776
+ #files;
1777
+ #modules;
1778
+ #sources = /* @__PURE__ */ new Map();
1779
+ constructor(options) {
1780
+ this.#files = options.files;
1781
+ this.#modules = options.modules;
1782
+ }
1783
+ source(specifier) {
1784
+ if (!Object.hasOwn(this.#modules, specifier)) return void 0;
1785
+ const module = this.#modules[specifier];
1786
+ if (module === void 0) return void 0;
1787
+ const key = moduleKey(module);
1788
+ const existing = this.#sources.get(key);
1789
+ if (existing !== void 0) return existing;
1790
+ const source = new Source({
1791
+ files: this.#files,
1792
+ module
1793
+ });
1794
+ this.#sources.set(key, source);
1795
+ return source;
1796
+ }
1797
+ };
1798
+ //#endregion
1720
1799
  //#region src/core/factories.ts
1721
1800
  /**
1722
1801
  * Create a structured {@link GuideInterface} view over one guide's markdown
1723
1802
  * source — parses once and caches its `sections` / `surface` / `methods` /
1724
- * `links` / `tests` / `patterns` projections.
1803
+ * `links` / `tests` / `fences` projections.
1725
1804
  *
1726
1805
  * @param source - The guide's markdown source text
1727
1806
  * @returns A working {@link GuideInterface}
@@ -1759,6 +1838,27 @@ function createSource(options) {
1759
1838
  return new Source(options);
1760
1839
  }
1761
1840
  /**
1841
+ * Create a {@link SourceManagerInterface} that resolves the consumer's local
1842
+ * import specifiers and shares one source view per module.
1843
+ *
1844
+ * @param options - The shared file inventory and specifier-to-module policy
1845
+ * @returns A source manager over the supplied policy
1846
+ *
1847
+ * @example
1848
+ * ```ts
1849
+ * import { createSourceManager } from '@orkestrel/guide'
1850
+ *
1851
+ * const sources = createSourceManager({
1852
+ * files: { 'src/core/index.ts': "export * from './types.js'" },
1853
+ * modules: { '@scope/package': 'src/core' },
1854
+ * })
1855
+ * sources.source('@scope/package')?.surface()
1856
+ * ```
1857
+ */
1858
+ function createSourceManager(options) {
1859
+ return new SourceManager(options);
1860
+ }
1861
+ /**
1762
1862
  * Compile the {@link surfaceSymbolShape} into a {@link ContractInterface} for
1763
1863
  * {@link SurfaceSymbol} — a guard, coercing parser, JSON Schema, and seeded
1764
1864
  * generator from one shape declaration (AGENTS §14).
@@ -1819,27 +1919,30 @@ exports.MANIFEST = MANIFEST;
1819
1919
  exports.METHODS = METHODS;
1820
1920
  exports.SURFACE = SURFACE;
1821
1921
  exports.Source = Source;
1922
+ exports.SourceManager = SourceManager;
1822
1923
  exports.TESTS = TESTS;
1823
1924
  exports.cellLinks = cellLinks;
1824
1925
  exports.createGuide = createGuide;
1825
1926
  exports.createManifestEntryContract = createManifestEntryContract;
1826
1927
  exports.createMethodGroupContract = createMethodGroupContract;
1827
1928
  exports.createSource = createSource;
1929
+ exports.createSourceManager = createSourceManager;
1828
1930
  exports.createSurfaceSymbolContract = createSurfaceSymbolContract;
1829
1931
  exports.declarationBody = declarationBody;
1830
1932
  exports.exampleMethods = exampleMethods;
1831
1933
  exports.examplesFrom = examplesFrom;
1832
1934
  exports.exportsFrom = exportsFrom;
1833
1935
  exports.extractExampleLines = extractExampleLines;
1936
+ exports.extractFences = extractFences;
1834
1937
  exports.extractLinks = extractLinks;
1835
1938
  exports.extractMethods = extractMethods;
1836
- exports.extractPatterns = extractPatterns;
1837
1939
  exports.extractSourceLines = extractSourceLines;
1838
1940
  exports.extractSurface = extractSurface;
1839
1941
  exports.extractTests = extractTests;
1840
1942
  exports.fenceImports = fenceImports;
1841
1943
  exports.findMissing = findMissing;
1842
1944
  exports.findUnexampled = findUnexampled;
1945
+ exports.findUnlisted = findUnlisted;
1843
1946
  exports.firstCode = firstCode;
1844
1947
  exports.hasCanonicalSegments = hasCanonicalSegments;
1845
1948
  exports.hiddenFrom = hiddenFrom;
@@ -1855,6 +1958,7 @@ exports.manifestEntryShape = manifestEntryShape;
1855
1958
  exports.memberMethods = memberMethods;
1856
1959
  exports.methodGroupShape = methodGroupShape;
1857
1960
  exports.missingSymbols = missingSymbols;
1961
+ exports.moduleKey = moduleKey;
1858
1962
  exports.normalizeDirectories = normalizeDirectories;
1859
1963
  exports.parseManifest = parseManifest;
1860
1964
  exports.resolveLink = resolveLink;
@@ -26,7 +26,7 @@ export declare function cellLinks(cell: readonly InlineNode[]): readonly string[
26
26
  /**
27
27
  * Create a structured {@link GuideInterface} view over one guide's markdown
28
28
  * source — parses once and caches its `sections` / `surface` / `methods` /
29
- * `links` / `tests` / `patterns` projections.
29
+ * `links` / `tests` / `fences` projections.
30
30
  *
31
31
  * @param source - The guide's markdown source text
32
32
  * @returns A working {@link GuideInterface}
@@ -95,6 +95,26 @@ export declare function createMethodGroupContract(): ContractInterface<MethodGro
95
95
  */
96
96
  export declare function createSource(options: SourceOptions): SourceInterface;
97
97
 
98
+ /**
99
+ * Create a {@link SourceManagerInterface} that resolves the consumer's local
100
+ * import specifiers and shares one source view per module.
101
+ *
102
+ * @param options - The shared file inventory and specifier-to-module policy
103
+ * @returns A source manager over the supplied policy
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { createSourceManager } from '@orkestrel/guide'
108
+ *
109
+ * const sources = createSourceManager({
110
+ * files: { 'src/core/index.ts': "export * from './types.js'" },
111
+ * modules: { '@scope/package': 'src/core' },
112
+ * })
113
+ * sources.source('@scope/package')?.surface()
114
+ * ```
115
+ */
116
+ export declare function createSourceManager(options: SourceManagerOptions): SourceManagerInterface;
117
+
98
118
  /**
99
119
  * Compile the {@link surfaceSymbolShape} into a {@link ContractInterface} for
100
120
  * {@link SurfaceSymbol} — a guard, coercing parser, JSON Schema, and seeded
@@ -235,6 +255,20 @@ export declare const EXTERNAL_SCHEMES: readonly string[];
235
255
  */
236
256
  export declare function extractExampleLines(lines: readonly SourceLine[]): readonly SourceLine[];
237
257
 
258
+ /**
259
+ * Every fenced code block anywhere in the guide document. A full AST walk
260
+ * includes fences nested inside blockquotes and lists.
261
+ *
262
+ * @param document - The parsed guide document
263
+ * @returns Every fence's language and verbatim code, in document order
264
+ *
265
+ * @example
266
+ * ```ts
267
+ * extractFences(document) // [{ language: 'ts', code: "import { X } from './x.js'\nX()" }]
268
+ * ```
269
+ */
270
+ export declare function extractFences(document: MarkdownDocument): readonly GuideFence[];
271
+
238
272
  /**
239
273
  * Every link href in the guide document, including table cells — a full,
240
274
  * depth-first walk of the whole AST.
@@ -264,20 +298,6 @@ export declare function extractLinks(document: MarkdownDocument): readonly strin
264
298
  */
265
299
  export declare function extractMethods(document: MarkdownDocument): readonly MethodGroup[];
266
300
 
267
- /**
268
- * Every ```ts fenced code block's body text anywhere in the guide document —
269
- * a full AST walk so a fence nested inside a blockquote or list still counts.
270
- *
271
- * @param document - The parsed guide document
272
- * @returns Every `ts`-lang fence's verbatim code, in walk order
273
- *
274
- * @example
275
- * ```ts
276
- * extractPatterns(document) // ["import { X } from './x.js'\nX()"]
277
- * ```
278
- */
279
- export declare function extractPatterns(document: MarkdownDocument): readonly string[];
280
-
281
301
  /**
282
302
  * Extract aligned physical source-line records in one character traversal.
283
303
  * Real line and block comments and complete template tokens become spaces in
@@ -353,10 +373,10 @@ export declare function extractTests(document: MarkdownDocument): readonly strin
353
373
  * fenceImports("import { a, b as c } from 'x'\n") // [{ specifier: 'x', names: ['a', 'b'] }]
354
374
  * ```
355
375
  */
356
- export declare function fenceImports(fence: string): readonly {
376
+ export declare function fenceImports(fence: string): ReadonlyArray<{
357
377
  specifier: string;
358
378
  names: readonly string[];
359
- }[];
379
+ }>;
360
380
 
361
381
  /**
362
382
  * The names present in `names` but absent from `source` — the set-difference
@@ -391,6 +411,22 @@ export declare function findMissing(names: readonly string[], source: readonly s
391
411
  */
392
412
  export declare function findUnexampled(names: readonly string[], fences: readonly string[], examples: readonly string[]): readonly string[];
393
413
 
414
+ /**
415
+ * The fences whose language is absent from the caller's listed languages.
416
+ * Untagged fences are always returned because they have no language to list.
417
+ *
418
+ * @param fences - The guide fences to check
419
+ * @param languages - The listed language tags
420
+ * @returns The unlisted fences in input order
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * findUnlisted([{ language: 'typescript', code: 'walk()' }], ['ts'])
425
+ * // [{ language: 'typescript', code: 'walk()' }]
426
+ * ```
427
+ */
428
+ export declare function findUnlisted(fences: readonly GuideFence[], languages: readonly string[]): readonly GuideFence[];
429
+
394
430
  /**
395
431
  * The first code-span value found by descending an inline node list, following
396
432
  * into `emphasis` / `link` / `image` children — the extraction rule behind a
@@ -409,7 +445,7 @@ export declare function firstCode(nodes: readonly InlineNode[]): string | undefi
409
445
  /**
410
446
  * A stateful, structured view over one parsed guide — the six documented
411
447
  * projections (`sections` / `surface` / `methods` / `links` / `tests` /
412
- * `patterns`) are extracted once at construction and cached.
448
+ * `fences`) are extracted once at construction and cached.
413
449
  *
414
450
  * @remarks
415
451
  * Pure: parses `source` once via `@orkestrel/markdown` and never touches the
@@ -433,7 +469,15 @@ export declare class Guide implements GuideInterface {
433
469
  methods(): readonly MethodGroup[];
434
470
  links(): readonly string[];
435
471
  tests(): readonly string[];
436
- patterns(): readonly string[];
472
+ fences(): readonly GuideFence[];
473
+ }
474
+
475
+ /** One fenced code block projected from a guide document. */
476
+ export declare interface GuideFence {
477
+ /** The info-string language tag, or `undefined` when the fence is untagged. */
478
+ readonly language: string | undefined;
479
+ /** The fence's verbatim code body. */
480
+ readonly code: string;
437
481
  }
438
482
 
439
483
  /**
@@ -466,14 +510,15 @@ export declare interface GuideInterface {
466
510
  */
467
511
  tests(): readonly string[];
468
512
  /**
469
- * Every fenced `ts` code block's body text, whole document.
513
+ * Every fenced code block in the whole document, in document order — no
514
+ * language filter, so a consumer decides which languages its checks read.
470
515
  *
471
516
  * @example
472
517
  * ```ts
473
- * guide.patterns() // ["import { createGuide } from '@orkestrel/guide'"]
518
+ * guide.fences() // [{ language: 'ts', code: "import { createGuide } from '@orkestrel/guide'" }]
474
519
  * ```
475
520
  */
476
- patterns(): readonly string[];
521
+ fences(): readonly GuideFence[];
477
522
  }
478
523
 
479
524
  /**
@@ -755,6 +800,22 @@ export declare const METHODS: string;
755
800
  */
756
801
  export declare function missingSymbols(symbols: readonly SurfaceSymbol[], source: readonly SurfaceSymbol[]): readonly string[];
757
802
 
803
+ /**
804
+ * The stable cache key for a {@link GuideModule}. Directories normalize before
805
+ * joining, so equivalent module spellings share one key. The NUL separator
806
+ * cannot occur in filesystem-backed canonical-segment inventory keys, so no
807
+ * directory boundary can collide with directory text.
808
+ *
809
+ * @param module - The module scope to key
810
+ * @returns The normalized directories joined by NUL
811
+ *
812
+ * @example
813
+ * ```ts
814
+ * moduleKey(['src/core', 'src/browser']) // 'src/core\0src/browser'
815
+ * ```
816
+ */
817
+ export declare function moduleKey(module: GuideModule): string;
818
+
758
819
  /**
759
820
  * A module scope normalized to its canonical directory list. `'.'` represents
760
821
  * workspace root; empty, trailing, and dot-segment spellings reduce through
@@ -1009,7 +1070,7 @@ export declare interface SourceInterface {
1009
1070
  *
1010
1071
  * @example
1011
1072
  * ```ts
1012
- * source.examples('GuideInterface') // ['links', 'tests', 'patterns']
1073
+ * source.examples('GuideInterface') // ['fences', 'links', 'tests']
1013
1074
  * ```
1014
1075
  */
1015
1076
  examples(name: string): readonly string[];
@@ -1030,6 +1091,50 @@ export declare interface SourceLine {
1030
1091
  readonly jsdoc: string | undefined;
1031
1092
  }
1032
1093
 
1094
+ /**
1095
+ * Resolves a consumer-owned import-specifier policy into pure source views and
1096
+ * caches those views by module, so aliases for one module share one entity.
1097
+ * Unmapped specifiers remain foreign to the consumer and return `undefined`.
1098
+ *
1099
+ * @example
1100
+ * ```ts
1101
+ * import { SourceManager } from '@orkestrel/guide'
1102
+ *
1103
+ * const sources = new SourceManager({
1104
+ * files: { 'src/core/index.ts': "export * from './types.js'" },
1105
+ * modules: { '@scope/package': 'src/core' },
1106
+ * })
1107
+ * sources.source('@scope/package')?.surface()
1108
+ * ```
1109
+ */
1110
+ export declare class SourceManager implements SourceManagerInterface {
1111
+ #private;
1112
+ constructor(options: SourceManagerOptions);
1113
+ source(specifier: string): SourceInterface | undefined;
1114
+ }
1115
+
1116
+ /** A specifier resolver that shares one {@link SourceInterface} per module. */
1117
+ export declare interface SourceManagerInterface {
1118
+ /**
1119
+ * Resolve a mapped specifier to its shared source view.
1120
+ *
1121
+ * @param specifier - The import specifier to resolve
1122
+ * @returns Its source view, or `undefined` when the specifier is not mapped
1123
+ */
1124
+ source(specifier: string): SourceInterface | undefined;
1125
+ }
1126
+
1127
+ /**
1128
+ * The construction input for a {@link SourceManager}: one shared file inventory
1129
+ * plus the consumer's specifier-to-module policy.
1130
+ */
1131
+ export declare interface SourceManagerOptions {
1132
+ /** The workspace's exact canonical-segment opaque inventory keys, root-relative path → text. */
1133
+ readonly files: Readonly<Record<string, string>>;
1134
+ /** Each local import specifier mapped to the source module it exposes. */
1135
+ readonly modules: Readonly<Record<string, GuideModule>>;
1136
+ }
1137
+
1033
1138
  /**
1034
1139
  * The construction input for a {@link Source} — a consumer-supplied file
1035
1140
  * inventory (root-relative path → file text) plus the module scope to