@orkestrel/guide 0.0.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["#sections","#surface","#methods","#links","#tests","#patterns","#files","#module","#exports","#scanSymbols","#declarationBody","#hidden","#examples","#scanExamples","#exampleMembers"],"sources":["../../../src/core/constants.ts","../../../src/core/helpers.ts","../../../src/core/validators.ts","../../../src/core/parsers.ts","../../../src/core/shapers.ts","../../../src/core/Guide.ts","../../../src/core/Source.ts","../../../src/core/factories.ts"],"sourcesContent":["/**\n * The `## Surface` heading text a guide's documented exports section is keyed on.\n */\nexport const SURFACE: string = 'Surface'\n\n/**\n * The `## Methods` heading text a guide's documented interface-methods section is keyed on.\n */\nexport const METHODS: string = 'Methods'\n\n/**\n * The `## Tests` heading text a guide's documented test-link section is keyed on.\n */\nexport const TESTS: string = 'Tests'\n\n/**\n * The `## By concept` heading text the manifest's run-map table is keyed on.\n */\nexport const MANIFEST: string = 'By concept'\n\n/**\n * The link `href` schemes a guides-parity link check skips as external — a link\n * with one of these prefixes (or a bare `#` anchor, handled separately in\n * `isExternalLink`) is never resolved against the filesystem.\n */\nexport const EXTERNAL_SCHEMES: readonly string[] = Object.freeze([\n\t'http:',\n\t'https:',\n\t'mailto:',\n\t'tel:',\n])\n","import type { InlineNode, TableNode } from '@orkestrel/markdown'\nimport {\n\tflattenText,\n\tisCodeSpanNode,\n\tisEmphasisNode,\n\tisLinkNode,\n\twalkNodes,\n} from '@orkestrel/markdown'\nimport type { GuideModule, SurfaceSymbol } from './types.js'\nimport { EXTERNAL_SCHEMES } from './constants.js'\n\n/**\n * A module scope normalized to its directory list — a single directory\n * becomes a one-element list so every scanner walks the same shape.\n *\n * @param module - The module scope to normalize\n * @returns The directory list `module` denotes\n *\n * @example\n * ```ts\n * moduleDirs('src/core') // ['src/core']\n * moduleDirs(['src/core', 'src/browser']) // ['src/core', 'src/browser']\n * ```\n */\nexport function moduleDirs(module: GuideModule): readonly string[] {\n\treturn typeof module === 'string' ? [module] : module\n}\n\n/**\n * The file inventory's keys belonging to a {@link GuideModule} scope, sorted —\n * a key belongs when it starts with one of the scope's directories, ends in\n * `.ts`, and is neither that directory's `index.ts` nor a `.test.ts` file.\n *\n * @param files - The workspace file inventory, root-relative path → file text\n * @param module - The module scope to filter to\n * @returns The scope's file keys, root-relative and sorted\n *\n * @example\n * ```ts\n * moduleKeys({ 'src/core/Guide.ts': '', 'src/core/index.ts': '' }, 'src/core') // ['src/core/Guide.ts']\n * ```\n */\nexport function moduleKeys(\n\tfiles: Readonly<Record<string, string>>,\n\tmodule: GuideModule,\n): readonly string[] {\n\tconst dirs = moduleDirs(module)\n\tconst keys: string[] = []\n\n\tfor (const key of Object.keys(files)) {\n\t\tif (!key.endsWith('.ts')) continue\n\t\tif (key.endsWith('.test.ts')) continue\n\n\t\tconst dir = dirs.find((candidate) => key.startsWith(`${candidate}/`))\n\t\tif (dir === undefined) continue\n\t\tif (key === `${dir}/index.ts`) continue\n\n\t\tkeys.push(key)\n\t}\n\n\treturn keys.sort()\n}\n\n/**\n * The bijection key for a surface symbol — its kind and name combined — so a\n * symbol-set comparison diffs (name, kind) pairs rather than names alone.\n *\n * @param symbol - The symbol to key\n * @returns The `${kind} ${name}` key\n *\n * @example\n * ```ts\n * symbolKey({ name: 'Markdown', kind: 'class' }) // 'class Markdown'\n * ```\n */\nexport function symbolKey(symbol: SurfaceSymbol): string {\n\treturn `${symbol.kind} ${symbol.name}`\n}\n\n/**\n * The names present in `names` but absent from `source` — the set-difference\n * behind a both-directions bijection assertion.\n *\n * @param names - The candidate names\n * @param source - The names to compare against\n * @returns The names in `names` that are not in `source`\n *\n * @example\n * ```ts\n * findMissing(['a', 'b'], ['a']) // ['b']\n * ```\n */\nexport function findMissing(\n\tnames: readonly string[],\n\tsource: readonly string[],\n): readonly string[] {\n\tconst existing = new Set(source)\n\treturn names.filter((name) => !existing.has(name))\n}\n\n/**\n * The symbol-key set-difference between two symbol lists — `symbols` present but\n * absent from `source`, compared by {@link symbolKey} so a symbol can drift in\n * neither name nor kind.\n *\n * @param symbols - The candidate symbols\n * @param source - The symbols to compare against\n * @returns The symbol keys in `symbols` that are not in `source`\n *\n * @example\n * ```ts\n * missingSymbols([{ name: 'X', kind: 'class' }], []) // ['class X']\n * ```\n */\nexport function missingSymbols(\n\tsymbols: readonly SurfaceSymbol[],\n\tsource: readonly SurfaceSymbol[],\n): readonly string[] {\n\treturn findMissing(symbols.map(symbolKey), source.map(symbolKey))\n}\n\n/**\n * The names in `names` that have no example — a fence containing the name at a\n * word boundary in `fences`, or a membership in `examples`, both count as\n * \"has an example\"; presence-only, fence and JSDoc content are never checked.\n *\n * @param names - The candidate symbol/member names to check\n * @param fences - The guide's ```ts Patterns fence bodies to search\n * @param examples - The names already known to carry an `@example` JSDoc block\n * @returns The names in `names` with no fence mention and no `@example`\n *\n * @example\n * ```ts\n * findUnexampled(['walk', 'fold'], ['walk()'], []) // ['fold']\n * findUnexampled(['walk'], [], ['walk']) // []\n * ```\n */\nexport function findUnexampled(\n\tnames: readonly string[],\n\tfences: readonly string[],\n\texamples: readonly string[],\n): readonly string[] {\n\tconst exampled = new Set(examples)\n\treturn names.filter((name) => {\n\t\tif (exampled.has(name)) return false\n\t\tconst boundary = new RegExp(`\\\\b${name}\\\\b`)\n\t\treturn !fences.some((fence) => boundary.test(fence))\n\t})\n}\n\n/**\n * Parse a fence's `import` statements into per-specifier imported identifier\n * names — handles `import type`, mixed multiline braces, and `x as y` aliases\n * (resolved to the local name `x`... the ORIGINAL exported name, since it is\n * the export that must exist in `source.exports()`).\n *\n * @param fence - A ```ts Patterns fence's verbatim body text\n * @returns One entry per `import ... from 'specifier'` statement, in fence order\n *\n * @example\n * ```ts\n * fenceImports(\"import { a, b as c } from 'x'\\n\") // [{ specifier: 'x', names: ['a', 'b'] }]\n * ```\n */\nexport function fenceImports(\n\tfence: string,\n): readonly { specifier: string; names: readonly string[] }[] {\n\tconst results: { specifier: string; names: readonly string[] }[] = []\n\tconst pattern = /import\\s+(?:type\\s+)?\\{([^}]*)\\}\\s*from\\s*['\"]([^'\"]+)['\"]/gs\n\n\tlet match: RegExpExecArray | null\n\twhile ((match = pattern.exec(fence)) !== null) {\n\t\tconst body = match[1]\n\t\tconst specifier = match[2]\n\t\tif (body === undefined || specifier === undefined) continue\n\n\t\tconst names = body\n\t\t\t.split(',')\n\t\t\t.map((part) => part.trim())\n\t\t\t.filter((part) => part.length > 0)\n\t\t\t.map((part) => part.replace(/^type\\s+/, ''))\n\t\t\t.map((part) => {\n\t\t\t\tconst asMatch = part.match(/^(\\w+)\\s+as\\s+\\w+$/)\n\t\t\t\treturn asMatch?.[1] ?? part\n\t\t\t})\n\t\t\t.filter((part) => /^\\w+$/.test(part))\n\n\t\tresults.push({ specifier, names })\n\t}\n\n\treturn results\n}\n\n/**\n * Whether a link `href` should be skipped by the guides-parity link checks — an\n * external scheme ({@link EXTERNAL_SCHEMES}) or a bare in-document `#` anchor.\n *\n * @param href - The link destination\n * @returns `true` when the link should not be resolved against the filesystem\n *\n * @example\n * ```ts\n * isExternalLink('https://example.com') // true\n * isExternalLink('../helpers.ts') // false\n * ```\n */\nexport function isExternalLink(href: string): boolean {\n\tif (href.startsWith('#')) return true\n\treturn EXTERNAL_SCHEMES.some((scheme) => href.startsWith(scheme))\n}\n\n/**\n * Resolve a relative link `target` against `from` and normalize the result — `from`\n * is treated as a file (its directory is everything before the last `/`) when it\n * carries a `/`, or as a bare directory itself when it does not; `.` segments drop\n * and `..` segments pop the preceding component, purely (no `node:path`).\n *\n * @param from - The declaring guide path (a file) or manifest base (a directory)\n * @param target - The relative link destination to resolve\n * @returns The normalized, workspace-root-relative path\n *\n * @example\n * ```ts\n * resolveLink('guides/src/markdown.md', '../../src/core/helpers.ts') // 'src/core/helpers.ts'\n * resolveLink('guides', '../src/core') // 'src/core'\n * ```\n */\nexport function resolveLink(from: string, target: string): string {\n\tconst index = from.lastIndexOf('/')\n\tconst dir = index < 0 ? from : from.slice(0, index)\n\tconst combined = dir === '' ? target : `${dir}/${target}`\n\tconst segments: string[] = []\n\n\tfor (const segment of combined.split('/')) {\n\t\tif (segment === '' || segment === '.') continue\n\t\tif (segment === '..') {\n\t\t\tif (segments.length > 0) segments.pop()\n\t\t\telse segments.push(segment)\n\t\t\tcontinue\n\t\t}\n\t\tsegments.push(segment)\n\t}\n\n\treturn segments.join('/')\n}\n\n/**\n * The first code-span value found by descending an inline node list, following\n * into `emphasis` / `link` children — the extraction rule behind a Surface or\n * Methods table row's first-column identifier.\n *\n * @param nodes - The inline nodes to search\n * @returns The first code span's literal text, or `undefined` when none is found\n *\n * @example\n * ```ts\n * firstCode([{ element: 'codeSpan', value: 'Markdown' }]) // 'Markdown'\n * ```\n */\nexport function firstCode(nodes: readonly InlineNode[]): string | undefined {\n\tfor (const node of nodes) {\n\t\tif (isCodeSpanNode(node)) return node.value\n\t\tif (isEmphasisNode(node) || isLinkNode(node)) {\n\t\t\tconst value = firstCode(node.children)\n\t\t\tif (value !== undefined) return value\n\t\t}\n\t}\n\treturn undefined\n}\n\n/**\n * The link hrefs found within one table cell's inline content.\n *\n * @param cell - The cell's inline nodes\n * @returns The cell's link hrefs, in walk order\n *\n * @example\n * ```ts\n * cellLinks([{ element: 'link', href: 'x.ts', children: [] }]) // ['x.ts']\n * ```\n */\nexport function cellLinks(cell: readonly InlineNode[]): readonly string[] {\n\tconst links: string[] = []\n\tfor (const node of walkNodes({ element: 'paragraph', children: cell })) {\n\t\tif (isLinkNode(node)) links.push(node.href)\n\t}\n\treturn links\n}\n\n/**\n * The identifier prefix of a code-span text — everything before its first `<`,\n * trimmed. Guide cells and headings may annotate a generic-parameterized name\n * (`MarkdownHandler<TNode, T>`) for readability, but the bijection key is the\n * bare identifier the source scanner captures, so both sides must normalize\n * the same way.\n *\n * @param code - A code span's literal text\n * @returns The identifier prefix, or an empty string when `code` is empty\n *\n * @example\n * ```ts\n * identifierOf('MarkdownHandler<TNode, T>') // 'MarkdownHandler'\n * identifierOf('fold') // 'fold'\n * ```\n */\nexport function identifierOf(code: string): string {\n\tconst index = code.indexOf('<')\n\treturn (index < 0 ? code : code.slice(0, index)).trim()\n}\n\n/**\n * The index of a table's `Kind` column, found by its header text so it survives\n * column reordering. The match is exact and case-sensitive (`'Kind'`) — a table\n * without that exact header contributes no symbols to the surface it feeds.\n *\n * @param table - The table to inspect\n * @returns The `Kind` column's index, or `undefined` when the table has no `Kind` header\n *\n * @example\n * ```ts\n * kindIndex(table) // 1, or undefined\n * ```\n */\nexport function kindIndex(table: TableNode): number | undefined {\n\tfor (let index = 0; index < table.header.length; index += 1) {\n\t\tconst cell = table.header[index]\n\t\tif (\n\t\t\tcell !== undefined &&\n\t\t\tflattenText({ element: 'paragraph', children: cell }).trim() === 'Kind'\n\t\t) {\n\t\t\treturn index\n\t\t}\n\t}\n\treturn undefined\n}\n","import type { Guard } from '@orkestrel/contract'\nimport type { ExportKind, ManifestEntry, MethodGroup, SurfaceSymbol } from './types.js'\nimport { arrayOf, isString, literalOf, recordOf, unionOf } from '@orkestrel/contract'\n\n// AGENTS section 14: guards are total. Every guard here validates an arbitrary\n// `unknown` value crossing an untrusted boundary (parsed guide/manifest data)\n// against a data type's full shape, composed from @orkestrel/contract\n// combinators and hoisted as module-level values (compiled once, not per call).\n\n/**\n * Whether `value` is one of the five documented {@link ExportKind} literals — the\n * guard behind extracting a Surface table's `Kind` cell into a typed symbol.\n *\n * @param value - The candidate value\n * @returns `true` when `value` is a valid {@link ExportKind}\n *\n * @example\n * ```ts\n * isExportKind('class') // true\n * isExportKind('enum') // false\n * ```\n */\nexport const isExportKind: Guard<ExportKind> = literalOf(\n\t'type',\n\t'interface',\n\t'const',\n\t'function',\n\t'class',\n)\n\n/**\n * Whether `value` is a well-formed {@link SurfaceSymbol} — a `name` string\n * paired with a valid {@link ExportKind}.\n *\n * @param value - The value to test\n * @returns `true` when `value` is a well-formed {@link SurfaceSymbol}\n *\n * @example\n * ```ts\n * isSurfaceSymbol({ name: 'Markdown', kind: 'class' }) // true\n * isSurfaceSymbol({ name: 'Markdown', kind: 'enum' }) // false\n * ```\n */\nexport const isSurfaceSymbol: Guard<SurfaceSymbol> = recordOf({\n\tname: isString,\n\tkind: isExportKind,\n})\n\n/**\n * Whether `value` is a well-formed {@link MethodGroup} — a backticked\n * `interface` name paired with its documented `methods`.\n *\n * @param value - The value to test\n * @returns `true` when `value` is a well-formed {@link MethodGroup}\n *\n * @example\n * ```ts\n * isMethodGroup({ interface: 'MarkdownInterface', methods: ['walk'] }) // true\n * isMethodGroup({ interface: 'MarkdownInterface', methods: [1] }) // false\n * ```\n */\nexport const isMethodGroup: Guard<MethodGroup> = recordOf({\n\tinterface: isString,\n\tmethods: arrayOf(isString),\n})\n\n/**\n * Whether `value` is a well-formed {@link ManifestEntry} — a `## By concept`\n * manifest row, its `source` accepting either a single directory or several.\n *\n * @param value - The value to test\n * @returns `true` when `value` is a well-formed {@link ManifestEntry}\n *\n * @example\n * ```ts\n * isManifestEntry({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true\n * isManifestEntry({ concept: 1 }) // false\n * ```\n */\nexport const isManifestEntry: Guard<ManifestEntry> = recordOf({\n\tconcept: isString,\n\tspec: isString,\n\tsource: unionOf(isString, arrayOf(isString)),\n\ttests: isString,\n})\n","import type { BlockNode, MarkdownDocument } from '@orkestrel/markdown'\nimport {\n\tcreateMarkdown,\n\tflattenText,\n\tisCodeBlockNode,\n\tisHeadingNode,\n\tisLinkNode,\n\tisTableNode,\n\twalkNodes,\n} from '@orkestrel/markdown'\nimport { isEmptyString, isNonEmptyArray, isNonEmptyString } from '@orkestrel/contract'\nimport type { DeclarationHead, ManifestEntry, MethodGroup, SurfaceSymbol } from './types.js'\nimport { MANIFEST, METHODS, SURFACE, TESTS } from './constants.js'\nimport { cellLinks, firstCode, identifierOf, kindIndex, resolveLink, symbolKey } from './helpers.js'\nimport { isExportKind } from './validators.js'\n\n/**\n * The module-scope exports declared in one file's source text — matches\n * `export (async)? (function(\\*)?|class|const|interface|type) Name`, deduped\n * by (kind, name). A generator export (`export function* walk`) scans as kind\n * `function` — its trailing `*` is stripped before the {@link ExportKind} check.\n *\n * @param source - The file's source text\n * @returns The file's exported symbols, in file order\n *\n * @example\n * ```ts\n * exportsFrom('export class Markdown {}\\n') // [{ name: 'Markdown', kind: 'class' }]\n * exportsFrom('export function* walk() {}\\n') // [{ name: 'walk', kind: 'function' }]\n * ```\n */\nexport function exportsFrom(source: string): readonly SurfaceSymbol[] {\n\tconst symbols: SurfaceSymbol[] = []\n\tconst seen = new Set<string>()\n\n\tfor (const line of source.split(/\\r?\\n/)) {\n\t\tconst match = line.match(/^export (?:async )?(function\\*?|class|const|interface|type) (\\w+)/)\n\t\tconst rawKind = match?.[1]\n\t\tconst name = match?.[2]\n\t\tconst kind = rawKind === undefined ? undefined : rawKind.replace(/\\*$/, '')\n\t\tif (!isNonEmptyString(kind) || !isNonEmptyString(name) || !isExportKind(kind)) continue\n\n\t\tconst key = `${kind} ${name}`\n\t\tif (seen.has(key)) continue\n\t\tseen.add(key)\n\t\tsymbols.push({ name, kind })\n\t}\n\n\treturn symbols\n}\n\n/**\n * The module-scope declarations LACKING the `export` keyword in one file's\n * source text — the mirror image of {@link exportsFrom}'s grammar, anchored\n * the same way (column 0, so an indented inner declaration never matches).\n * Scans only the five {@link ExportKind} keywords (`function` / `class` /\n * `const` / `interface` / `type`) — a module-scope `let` or `var` is a\n * different violation class (AGENTS §1 bans `var`; a bare `let` is not a\n * declaration kind this scanner's five-kind grammar covers) and is out of\n * this check's contract.\n *\n * @param source - The file's source text\n * @returns The file's hidden (non-exported) symbols, in file order\n *\n * @example\n * ```ts\n * hiddenFrom('function secretHelper() {}\\n') // [{ name: 'secretHelper', kind: 'function' }]\n * hiddenFrom('export class X {}\\n') // []\n * ```\n */\nexport function hiddenFrom(source: string): readonly SurfaceSymbol[] {\n\tconst symbols: SurfaceSymbol[] = []\n\tconst seen = new Set<string>()\n\n\tfor (const line of source.split(/\\r?\\n/)) {\n\t\tif (line.startsWith('export ')) continue\n\t\tconst match = line.match(/^(?:async )?(function\\*?|class|const|interface|type) (\\w+)/)\n\t\tconst rawKind = match?.[1]\n\t\tconst name = match?.[2]\n\t\tconst kind = rawKind === undefined ? undefined : rawKind.replace(/\\*$/, '')\n\t\tif (!isNonEmptyString(kind) || !isNonEmptyString(name) || !isExportKind(kind)) continue\n\n\t\tconst key = `${kind} ${name}`\n\t\tif (seen.has(key)) continue\n\t\tseen.add(key)\n\t\tsymbols.push({ name, kind })\n\t}\n\n\treturn symbols\n}\n\n/**\n * Join the declaration head starting at `start` into one space-separated\n * line, consuming lines until the first that ends with `{`.\n *\n * @param lines - The file's source lines\n * @param start - The index of the head's first line\n * @returns The joined head, or `undefined` when no line opens a body\n *\n * @example\n * ```ts\n * joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }\n * ```\n */\nexport function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined {\n\tconst parts: string[] = []\n\n\tfor (let index = start; index < lines.length; index += 1) {\n\t\tconst line = lines[index]\n\t\tif (line === undefined) break\n\t\tparts.push(index === start ? line.trimEnd() : line.trim())\n\t\tif (line.trimEnd().endsWith('{')) return { text: parts.join(' '), end: index }\n\t}\n\n\treturn undefined\n}\n\n/**\n * The body lines of the named `export class` / `export interface` declaration\n * within one file's source text — everything between the head's opening `{`\n * and the column-0 closing `}`.\n *\n * @param source - The file's source text to search\n * @param keyword - Whether to look for a `class` or an `interface`\n * @param name - The declaration's identifier\n * @returns The declaration's body lines, or an empty array when `source` does not declare it\n *\n * @example\n * ```ts\n * declarationBody('export interface X {\\n\\twalk(): void\\n}\\n', 'interface', 'X') // ['\\twalk(): void']\n * ```\n */\nexport function declarationBody(\n\tsource: string,\n\tkeyword: 'class' | 'interface',\n\tname: string,\n): readonly string[] {\n\tconst opener = `export ${keyword} ${name}`\n\tconst declaration = new RegExp(`^export ${keyword} ${name}(?:<.*>)?(?: .*)? \\\\{$`)\n\tconst lines = source.split(/\\r?\\n/)\n\n\tfor (let index = 0; index < lines.length; index += 1) {\n\t\tconst line = lines[index]\n\t\tif (line === undefined || !line.startsWith(opener)) continue\n\n\t\tconst head = joinHead(lines, index)\n\t\tif (head === undefined || !declaration.test(head.text)) continue\n\n\t\tconst body: string[] = []\n\t\tfor (const member of lines.slice(head.end + 1)) {\n\t\t\tif (member === '}') return body\n\t\t\tbody.push(member)\n\t\t}\n\n\t\t// Unterminated body — keep scanning in case a later match succeeds.\n\t}\n\n\treturn []\n}\n\n/**\n * The member lines declaring a callable member: plain, `async`, generator\n * (`*`), and optional (`records?(`) methods all count; getters, setters,\n * `static` members, and `#` privates never do (their keyword or `#` breaks\n * the `name(` shape).\n *\n * @param lines - A declaration's body lines\n * @returns The declared method names, deduped and sorted\n *\n * @example\n * ```ts\n * memberMethods(['\\tmap(): void', '\\tfilter(): void']) // ['filter', 'map']\n * ```\n */\nexport function memberMethods(lines: readonly string[]): readonly string[] {\n\tconst methods: string[] = []\n\n\tfor (const line of lines) {\n\t\tconst method = line.match(/^\\t(?:async )?\\*?(\\w+)(<.*>)?\\??\\(/)\n\t\tif (method?.[1] !== undefined) methods.push(method[1])\n\t}\n\n\treturn Array.from(new Set(methods)).sort()\n}\n\n/**\n * The block nodes under the named `##` heading, up to the next `##`-or-higher\n * heading (or the document's end) — the section-scoping window `extractSurface` /\n * `extractMethods` walk over.\n *\n * @param document - The parsed guide document\n * @param heading - The `##` heading text to scope to (e.g. `Surface`)\n * @returns The blocks belonging to that section, in document order\n *\n * @example\n * ```ts\n * sectionBlocks(document, 'Surface') // the blocks between `## Surface` and the next `##`\n * ```\n */\nexport function sectionBlocks(document: MarkdownDocument, heading: string): readonly BlockNode[] {\n\tconst blocks: BlockNode[] = []\n\tlet active = false\n\n\tfor (const block of document.children) {\n\t\tif (isHeadingNode(block) && block.level <= 2) {\n\t\t\tif (block.level === 2 && flattenText(block).trim() === heading) {\n\t\t\t\tactive = true\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (active) break\n\t\t}\n\n\t\tif (active) blocks.push(block)\n\t}\n\n\treturn blocks\n}\n\n/**\n * Every `## Surface` identifier the guide documents — each table row's column 0\n * code span (the name) paired with its `Kind` column (located by header text)\n * UNION every backticked H3 entity heading in the section\n * (`{name: <codeSpan>, kind: 'class'}`), deduped by {@link symbolKey}. A row with\n * no code-span name, or an unrecognized `Kind` text, is skipped.\n *\n * @param document - The parsed guide document\n * @returns The documented surface, in encounter order\n *\n * @example\n * ```ts\n * extractSurface(document) // [{ name: 'Markdown', kind: 'class' }, ...]\n * ```\n */\nexport function extractSurface(document: MarkdownDocument): readonly SurfaceSymbol[] {\n\tconst symbols: SurfaceSymbol[] = []\n\tconst seen = new Set<string>()\n\n\tfor (const block of sectionBlocks(document, SURFACE)) {\n\t\tif (isTableNode(block)) {\n\t\t\tconst column = kindIndex(block)\n\t\t\tfor (const row of block.rows) {\n\t\t\t\tconst nameCell = row[0]\n\t\t\t\tconst rawName = nameCell === undefined ? undefined : firstCode(nameCell)\n\t\t\t\tconst name = rawName === undefined ? undefined : identifierOf(rawName)\n\t\t\t\tif (name === undefined) continue\n\n\t\t\t\tconst kindCell = column === undefined ? undefined : row[column]\n\t\t\t\tconst kindText =\n\t\t\t\t\tkindCell === undefined\n\t\t\t\t\t\t? ''\n\t\t\t\t\t\t: flattenText({ element: 'paragraph', children: kindCell }).trim()\n\t\t\t\tif (!isExportKind(kindText)) continue\n\n\t\t\t\tconst symbol: SurfaceSymbol = { name, kind: kindText }\n\t\t\t\tconst key = symbolKey(symbol)\n\t\t\t\tif (seen.has(key)) continue\n\t\t\t\tseen.add(key)\n\t\t\t\tsymbols.push(symbol)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isHeadingNode(block) && block.level === 3) {\n\t\t\tconst rawName = firstCode(block.children)\n\t\t\tconst name = rawName === undefined ? undefined : identifierOf(rawName)\n\t\t\tif (name === undefined) continue\n\t\t\tconst symbol: SurfaceSymbol = { name, kind: 'class' }\n\t\t\tconst key = symbolKey(symbol)\n\t\t\tif (seen.has(key)) continue\n\t\t\tseen.add(key)\n\t\t\tsymbols.push(symbol)\n\t\t}\n\t}\n\n\treturn symbols\n}\n\n/**\n * One {@link MethodGroup} per documented behavioral interface in `## Methods` —\n * an H4 with a code span sets the current interface, and the table immediately\n * following becomes its documented methods.\n *\n * @param document - The parsed guide document\n * @returns The documented method groups, in document order\n *\n * @example\n * ```ts\n * extractMethods(document) // [{ interface: 'MarkdownInterface', methods: ['walk', ...] }]\n * ```\n */\nexport function extractMethods(document: MarkdownDocument): readonly MethodGroup[] {\n\tconst groups: MethodGroup[] = []\n\tlet current: string | undefined\n\n\tfor (const block of sectionBlocks(document, METHODS)) {\n\t\tif (isHeadingNode(block) && block.level === 4) {\n\t\t\tconst rawInterface = firstCode(block.children)\n\t\t\tcurrent = rawInterface === undefined ? undefined : identifierOf(rawInterface)\n\t\t\tcontinue\n\t\t}\n\n\t\tif (isTableNode(block) && current !== undefined) {\n\t\t\tconst methods: string[] = []\n\t\t\tfor (const row of block.rows) {\n\t\t\t\tconst cell = row[0]\n\t\t\t\tconst rawName = cell === undefined ? undefined : firstCode(cell)\n\t\t\t\tconst name = rawName === undefined ? undefined : identifierOf(rawName)\n\t\t\t\tif (name !== undefined) methods.push(name)\n\t\t\t}\n\t\t\tgroups.push({ interface: current, methods })\n\t\t\tcurrent = undefined\n\t\t}\n\t}\n\n\treturn groups\n}\n\n/**\n * Every link href in the guide document, including table cells — a full,\n * depth-first walk of the whole AST.\n *\n * @param document - The parsed guide document\n * @returns Every link's href, in walk order\n *\n * @example\n * ```ts\n * extractLinks(document) // ['../../src/core/helpers.ts', 'https://example.com']\n * ```\n */\nexport function extractLinks(document: MarkdownDocument): readonly string[] {\n\tconst links: string[] = []\n\tfor (const node of walkNodes(document)) {\n\t\tif (isLinkNode(node)) links.push(node.href)\n\t}\n\treturn links\n}\n\n/**\n * The relative test links declared under `## Tests` — every link href found\n * within that section only.\n *\n * @param document - The parsed guide document\n * @returns The `## Tests` section's link hrefs, in walk order\n *\n * @example\n * ```ts\n * extractTests(document) // ['../../tests/src/core/Markdown.test.ts', ...]\n * ```\n */\nexport function extractTests(document: MarkdownDocument): readonly string[] {\n\tconst links: string[] = []\n\tfor (const block of sectionBlocks(document, TESTS)) {\n\t\tfor (const node of walkNodes(block)) {\n\t\t\tif (isLinkNode(node)) links.push(node.href)\n\t\t}\n\t}\n\treturn links\n}\n\n/**\n * The exported functions in one file's source text whose immediately preceding\n * JSDoc block carries `@example` — walked line by line, tracking the current\n * comment block; the block resets on any non-comment, non-export line so an\n * `@example` never attaches to a declaration it does not directly precede.\n *\n * @param source - The file's source text\n * @returns The exported function names with an `@example`, in file order\n *\n * @example\n * ```ts\n * const block = ['/**', ' * @example', ' *' + '/', 'export function walk() {}', ''].join('\\n')\n * examplesFrom(block) // ['walk']\n * examplesFrom('export function walk() {}\\n') // []\n * ```\n */\nexport function examplesFrom(source: string): readonly string[] {\n\tconst names: string[] = []\n\tconst seen = new Set<string>()\n\tlet inBlock = false\n\tlet blockHasExample = false\n\tlet pending = false\n\n\tfor (const line of source.split(/\\r?\\n/)) {\n\t\tconst trimmed = line.trim()\n\n\t\tif (!inBlock && trimmed.startsWith('/**')) {\n\t\t\tinBlock = true\n\t\t\tblockHasExample = trimmed.includes('@example')\n\t\t\tpending = false\n\t\t\tif (trimmed.length > 3 && trimmed.endsWith('*/')) {\n\t\t\t\tinBlock = false\n\t\t\t\tpending = blockHasExample\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (inBlock) {\n\t\t\tif (trimmed.includes('@example')) blockHasExample = true\n\t\t\tif (trimmed.endsWith('*/')) {\n\t\t\t\tinBlock = false\n\t\t\t\tpending = blockHasExample\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tconst match = line.match(/^export (?:async )?function\\*? (\\w+)/)\n\t\tconst name = match?.[1]\n\t\tif (pending && isNonEmptyString(name) && !seen.has(name)) {\n\t\t\tseen.add(name)\n\t\t\tnames.push(name)\n\t\t}\n\t\tpending = false\n\t}\n\n\treturn names\n}\n\n/**\n * The callable-member names in a declaration body (per {@link memberMethods}'\n * grammar) whose immediately preceding JSDoc block, within the same body,\n * carries `@example` — the member-level mirror of {@link examplesFrom}.\n *\n * @param lines - A declaration's body lines\n * @returns The exemplified member names, deduped and sorted\n *\n * @example\n * ```ts\n * exampleMethods(['\\t/**', '\\t * @example', '\\t *' + '/', '\\twalk(): void']) // ['walk']\n * ```\n */\nexport function exampleMethods(lines: readonly string[]): readonly string[] {\n\tconst methods: string[] = []\n\tconst seen = new Set<string>()\n\tlet inBlock = false\n\tlet blockHasExample = false\n\tlet pending = false\n\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trim()\n\n\t\tif (!inBlock && trimmed.startsWith('/**')) {\n\t\t\tinBlock = true\n\t\t\tblockHasExample = trimmed.includes('@example')\n\t\t\tpending = false\n\t\t\tif (trimmed.length > 3 && trimmed.endsWith('*/')) {\n\t\t\t\tinBlock = false\n\t\t\t\tpending = blockHasExample\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif (inBlock) {\n\t\t\tif (trimmed.includes('@example')) blockHasExample = true\n\t\t\tif (trimmed.endsWith('*/')) {\n\t\t\t\tinBlock = false\n\t\t\t\tpending = blockHasExample\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tconst method = line.match(/^\\t(?:async )?\\*?(\\w+)(<.*>)?\\??\\(/)\n\t\tconst name = method?.[1]\n\t\tif (pending && isNonEmptyString(name) && !seen.has(name)) {\n\t\t\tseen.add(name)\n\t\t\tmethods.push(name)\n\t\t}\n\t\tpending = false\n\t}\n\n\treturn Array.from(new Set(methods)).sort()\n}\n\n/**\n * Every ```ts fenced code block's body text anywhere in the guide document —\n * a full AST walk so a fence nested inside a blockquote or list still counts.\n *\n * @param document - The parsed guide document\n * @returns Every `ts`-lang fence's verbatim code, in walk order\n *\n * @example\n * ```ts\n * extractPatterns(document) // [\"import { X } from './x.js'\\nX()\"]\n * ```\n */\nexport function extractPatterns(document: MarkdownDocument): readonly string[] {\n\tconst patterns: string[] = []\n\tfor (const node of walkNodes(document)) {\n\t\tif (isCodeBlockNode(node) && node.lang === 'ts') patterns.push(node.code)\n\t}\n\treturn patterns\n}\n\n/**\n * Parse a `## By concept` manifest table into its {@link ManifestEntry} rows —\n * each row's Concept cell (flattened text), Spec / Tests cells (a single link\n * href, resolved against `base`), and Source cell (every link href, resolved\n * against `base`; one directory collapses to a `string`, several become a\n * `readonly string[]`). A row missing a concept, spec link, tests link, or\n * source link is skipped as malformed.\n *\n * @param markdown - The manifest markdown source (e.g. `guides/README.md`'s content)\n * @param base - A single directory name relative to the workspace root that the manifest's\n * links are resolved against (e.g. `'guides'`) — {@link resolveLink}'s arithmetic supports\n * only one path segment, so a deeper or nested base is not supported\n * @returns The manifest's entries, in row order\n *\n * @example\n * ```ts\n * parseManifest(readme, 'guides') // [{ concept: 'Markdown', spec: 'guides/src/markdown.md', ... }]\n * ```\n */\nexport function parseManifest(markdown: string, base: string): readonly ManifestEntry[] {\n\tconst document = createMarkdown(markdown).document\n\tconst entries: ManifestEntry[] = []\n\n\tfor (const block of sectionBlocks(document, MANIFEST)) {\n\t\tif (!isTableNode(block)) continue\n\n\t\tfor (const row of block.rows) {\n\t\t\tconst conceptCell = row[0]\n\t\t\tconst specCell = row[1]\n\t\t\tconst sourceCell = row[2]\n\t\t\tconst testsCell = row[3]\n\t\t\tif (\n\t\t\t\tconceptCell === undefined ||\n\t\t\t\tspecCell === undefined ||\n\t\t\t\tsourceCell === undefined ||\n\t\t\t\ttestsCell === undefined\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tconst concept = flattenText({ element: 'paragraph', children: conceptCell }).trim()\n\t\t\tif (isEmptyString(concept)) continue\n\n\t\t\tconst specHref = cellLinks(specCell)[0]\n\t\t\tconst testsHref = cellLinks(testsCell)[0]\n\t\t\tif (specHref === undefined || testsHref === undefined) continue\n\n\t\t\tconst sourceHrefs = cellLinks(sourceCell).map((href) => resolveLink(base, href))\n\t\t\tif (!isNonEmptyArray<string>(sourceHrefs)) continue\n\t\t\tconst [firstSource] = sourceHrefs\n\t\t\tconst source = sourceHrefs.length === 1 ? firstSource : sourceHrefs\n\n\t\t\tentries.push({\n\t\t\t\tconcept,\n\t\t\t\tspec: resolveLink(base, specHref),\n\t\t\t\tsource,\n\t\t\t\ttests: resolveLink(base, testsHref),\n\t\t\t})\n\t\t}\n\t}\n\n\treturn entries\n}\n","import { arrayShape, literalShape, objectShape, stringShape, unionShape } from '@orkestrel/contract'\n\n// AGENTS section 14 / 4.6.1: shapers are `ContractShape` VALUES, not functions\n// or types - a JSON-Schema blueprint the compilers (factories.ts) turn into a\n// guard / parser / schema / generator in lockstep. Every documented data type\n// here is non-recursive, so each shapes directly (no `lazyOf` gate needed).\n\n/**\n * The shape of a {@link SurfaceSymbol} — a documented / exported symbol's\n * `name` paired with its {@link ExportKind}.\n *\n * @example\n * ```ts\n * import { createContract } from '@orkestrel/contract'\n * import { surfaceSymbolShape } from '@orkestrel/guide/core'\n *\n * const surfaceSymbol = createContract(surfaceSymbolShape)\n * surfaceSymbol.is({ name: 'Markdown', kind: 'class' }) // true\n * ```\n */\nexport const surfaceSymbolShape = objectShape({\n\tname: stringShape(),\n\tkind: literalShape(['type', 'interface', 'const', 'function', 'class']),\n})\n\n/**\n * The shape of a {@link MethodGroup} — a backticked `interface` name paired\n * with its documented `methods`.\n *\n * @example\n * ```ts\n * import { createContract } from '@orkestrel/contract'\n * import { methodGroupShape } from '@orkestrel/guide/core'\n *\n * const methodGroup = createContract(methodGroupShape)\n * methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true\n * ```\n */\nexport const methodGroupShape = objectShape({\n\tinterface: stringShape(),\n\tmethods: arrayShape(stringShape()),\n})\n\n/**\n * The shape of a {@link ManifestEntry} — one `## By concept` manifest row,\n * `source` accepting either a single directory or several.\n *\n * @example\n * ```ts\n * import { createContract } from '@orkestrel/contract'\n * import { manifestEntryShape } from '@orkestrel/guide/core'\n *\n * const manifestEntry = createContract(manifestEntryShape)\n * manifestEntry.is({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true\n * ```\n */\nexport const manifestEntryShape = objectShape({\n\tconcept: stringShape(),\n\tspec: stringShape(),\n\tsource: unionShape(stringShape(), arrayShape(stringShape())),\n\ttests: stringShape(),\n})\n","import { createMarkdown, flattenText, isHeadingNode } from '@orkestrel/markdown'\nimport type { GuideInterface, MethodGroup, SurfaceSymbol } from './types.js'\nimport {\n\textractLinks,\n\textractMethods,\n\textractPatterns,\n\textractSurface,\n\textractTests,\n} from './parsers.js'\n\n/**\n * A stateful, structured view over one parsed guide — the five documented\n * projections (`sections` / `surface` / `methods` / `links` / `tests`) are\n * extracted once at construction and cached.\n *\n * @remarks\n * Pure: parses `source` once via `@orkestrel/markdown` and never touches the\n * filesystem — `Guide` has no notion of \"where\" the guide came from, only its\n * markdown text. Every accessor returns the same cached, readonly array on\n * every call.\n *\n * @example\n * ```ts\n * import { Guide } from '@orkestrel/guide/core'\n *\n * const guide = new Guide('## Surface\\n\\n| Name | Kind |\\n| --- | --- |\\n| `X` | class |')\n * guide.surface() // [{ name: 'X', kind: 'class' }]\n * ```\n */\nexport class Guide implements GuideInterface {\n\treadonly #sections: readonly string[]\n\treadonly #surface: readonly SurfaceSymbol[]\n\treadonly #methods: readonly MethodGroup[]\n\treadonly #links: readonly string[]\n\treadonly #tests: readonly string[]\n\treadonly #patterns: readonly string[]\n\n\tconstructor(source: string) {\n\t\tconst document = createMarkdown(source).document\n\n\t\tthis.#sections = document.children\n\t\t\t.filter(isHeadingNode)\n\t\t\t.filter((heading) => heading.level === 2)\n\t\t\t.map((heading) => flattenText(heading).trim())\n\t\tthis.#surface = extractSurface(document)\n\t\tthis.#methods = extractMethods(document)\n\t\tthis.#links = extractLinks(document)\n\t\tthis.#tests = extractTests(document)\n\t\tthis.#patterns = extractPatterns(document)\n\t}\n\n\tsections(): readonly string[] {\n\t\treturn this.#sections\n\t}\n\n\tsurface(): readonly SurfaceSymbol[] {\n\t\treturn this.#surface\n\t}\n\n\tmethods(): readonly MethodGroup[] {\n\t\treturn this.#methods\n\t}\n\n\tlinks(): readonly string[] {\n\t\treturn this.#links\n\t}\n\n\ttests(): readonly string[] {\n\t\treturn this.#tests\n\t}\n\n\tpatterns(): readonly string[] {\n\t\treturn this.#patterns\n\t}\n}\n","import type { GuideModule, SourceInterface, SourceOptions, SurfaceSymbol } from './types.js'\nimport { moduleKeys, symbolKey } from './helpers.js'\nimport {\n\tdeclarationBody,\n\texampleMethods,\n\texamplesFrom,\n\texportsFrom,\n\thiddenFrom,\n\tmemberMethods,\n} from './parsers.js'\n\n/**\n * A pure `SourceInterface` — reflects a module scope's exports and member\n * methods over a consumer-supplied file inventory (AGENTS §22, `PROPOSAL.md`\n * §7), using text-only line scanners rather than the TypeScript compiler API\n * or the filesystem. `Source` never touches disk: the consumer gathers the\n * inventory however their environment allows (`node:fs` in a Node script,\n * `import.meta.glob` in a browser/vitest run) and passes it in as `files`.\n *\n * @example\n * ```ts\n * import { Source } from '@orkestrel/guide'\n *\n * const source = new Source({\n * \tfiles: {\n * \t\t'src/core/Guide.ts': 'export class Guide {}\\n',\n * \t\t'src/core/types.ts': 'export interface GuideInterface {\\n\\tsections(): void\\n}\\n',\n * \t},\n * \tmodule: 'src/core',\n * })\n * source.exports() // [{ name: 'Guide', kind: 'class' }, { name: 'GuideInterface', kind: 'interface' }]\n * source.methods('GuideInterface') // ['sections']\n * source.exists('src/core/Guide.ts') // true\n * ```\n */\nexport class Source implements SourceInterface {\n\treadonly #files: Readonly<Record<string, string>>\n\treadonly #module: GuideModule\n\t#exports: readonly SurfaceSymbol[] | undefined\n\t#hidden: readonly SurfaceSymbol[] | undefined\n\t#examples: readonly string[] | undefined\n\n\tconstructor(options: SourceOptions) {\n\t\tthis.#files = options.files\n\t\tthis.#module = options.module\n\t}\n\n\t// The module's exports are computed once on first access and cached —\n\t// every subsequent call reuses the same scan of an immutable inventory.\n\texports(): readonly SurfaceSymbol[] {\n\t\tif (this.#exports === undefined) this.#exports = this.#scanSymbols(exportsFrom)\n\t\treturn this.#exports\n\t}\n\n\tmethods(name: string): readonly string[] {\n\t\tconst interfaceBody = this.#declarationBody('interface', name)\n\t\tif (interfaceBody.length > 0) return memberMethods(interfaceBody)\n\n\t\tconst classBody = this.#declarationBody('class', name)\n\t\treturn memberMethods(classBody).filter((method) => method !== 'constructor')\n\t}\n\n\texists(relative: string): boolean {\n\t\tconst keys = Object.keys(this.#files)\n\t\treturn keys.some((key) => key === relative || key.startsWith(`${relative}/`))\n\t}\n\n\t// The module's hidden declarations are computed once on first access and\n\t// cached — mirrors `exports()`'s caching.\n\thidden(): readonly SurfaceSymbol[] {\n\t\tif (this.#hidden === undefined) this.#hidden = this.#scanSymbols(hiddenFrom)\n\t\treturn this.#hidden\n\t}\n\n\texamples(): readonly string[]\n\texamples(name: string): readonly string[]\n\texamples(name?: string): readonly string[] {\n\t\tif (name === undefined) {\n\t\t\tif (this.#examples === undefined) this.#examples = this.#scanExamples()\n\t\t\treturn this.#examples\n\t\t}\n\n\t\treturn this.#exampleMembers(name)\n\t}\n\n\t// The union of exported-function `@example` names across the module's\n\t// files, deduped in first-seen order — mirrors `#scanSymbols`, but over a\n\t// plain string scanner (`examplesFrom`) rather than a `SurfaceSymbol` one.\n\t#scanExamples(): readonly string[] {\n\t\tconst names: string[] = []\n\t\tconst seen = new Set<string>()\n\n\t\tfor (const key of moduleKeys(this.#files, this.#module)) {\n\t\t\tconst text = this.#files[key]\n\t\t\tif (text === undefined) continue\n\n\t\t\tfor (const name of examplesFrom(text)) {\n\t\t\t\tif (seen.has(name)) continue\n\t\t\t\tseen.add(name)\n\t\t\t\tnames.push(name)\n\t\t\t}\n\t\t}\n\n\t\treturn names\n\t}\n\n\t// The `@example`-carrying members of the interface-or-class declaration\n\t// body named `name`, unioning both shapes (an implementer may carry its\n\t// own `@example` a documented interface member does not, or vice versa).\n\t#exampleMembers(name: string): readonly string[] {\n\t\tconst interfaceBody = this.#declarationBody('interface', name)\n\t\tconst classBody = this.#declarationBody('class', name)\n\t\tconst members = new Set<string>([\n\t\t\t...exampleMethods(interfaceBody),\n\t\t\t...exampleMethods(classBody),\n\t\t])\n\t\treturn Array.from(members).sort()\n\t}\n\n\t// The pure union-and-dedupe-and-sort composition behind `exports()` and\n\t// `hidden()` — kept as a private method because it orchestrates a scanner\n\t// across every file of the module scope rather than being a self-contained\n\t// leaf.\n\t#scanSymbols(scan: (source: string) => readonly SurfaceSymbol[]): readonly SurfaceSymbol[] {\n\t\tconst symbols: SurfaceSymbol[] = []\n\t\tconst seen = new Set<string>()\n\n\t\tfor (const key of moduleKeys(this.#files, this.#module)) {\n\t\t\tconst text = this.#files[key]\n\t\t\tif (text === undefined) continue\n\n\t\t\tfor (const symbol of scan(text)) {\n\t\t\t\tconst identity = symbolKey(symbol)\n\t\t\t\tif (seen.has(identity)) continue\n\t\t\t\tseen.add(identity)\n\t\t\t\tsymbols.push(symbol)\n\t\t\t}\n\t\t}\n\n\t\treturn symbols.sort((a, b) => (a.name === b.name ? 0 : a.name < b.name ? -1 : 1))\n\t}\n\n\t// The first non-empty declaration body found across the module scope's\n\t// files, searched in sorted file order until one file declares `name`.\n\t#declarationBody(keyword: 'class' | 'interface', name: string): readonly string[] {\n\t\tfor (const key of moduleKeys(this.#files, this.#module)) {\n\t\t\tconst text = this.#files[key]\n\t\t\tif (text === undefined) continue\n\n\t\t\tconst body = declarationBody(text, keyword, name)\n\t\t\tif (body.length > 0) return body\n\t\t}\n\n\t\treturn []\n\t}\n}\n","import type { ContractInterface } from '@orkestrel/contract'\nimport type {\n\tGuideInterface,\n\tManifestEntry,\n\tMethodGroup,\n\tSourceInterface,\n\tSourceOptions,\n\tSurfaceSymbol,\n} from './types.js'\nimport { createContract } from '@orkestrel/contract'\nimport { Guide } from './Guide.js'\nimport { Source } from './Source.js'\nimport { manifestEntryShape, methodGroupShape, surfaceSymbolShape } from './shapers.js'\n\n/**\n * Create a structured {@link GuideInterface} view over one guide's markdown\n * source — parses once and caches its `sections` / `surface` / `methods` /\n * `links` / `tests` projections.\n *\n * @param source - The guide's markdown source text\n * @returns A working {@link GuideInterface}\n *\n * @example\n * ```ts\n * import { createGuide } from '@orkestrel/guide'\n *\n * const guide = createGuide('## Surface\\n\\n| Name | Kind |\\n| --- | --- |\\n| `X` | class |')\n * guide.surface() // [{ name: 'X', kind: 'class' }]\n * ```\n */\nexport function createGuide(source: string): GuideInterface {\n\treturn new Guide(source)\n}\n\n/**\n * Create a pure {@link SourceInterface} over a consumer-supplied file\n * inventory — see {@link Source}.\n *\n * @param options - The file inventory and module scope to reflect\n * @returns A `SourceInterface` reflecting the given module scope\n *\n * @example\n * ```ts\n * import { createSource } from '@orkestrel/guide'\n *\n * const source = createSource({\n * \tfiles: { 'src/core/Guide.ts': 'export class Guide {}\\n' },\n * \tmodule: 'src/core',\n * })\n * source.exports() // [{ name: 'Guide', kind: 'class' }]\n * ```\n */\nexport function createSource(options: SourceOptions): SourceInterface {\n\treturn new Source(options)\n}\n\n/**\n * Compile the {@link surfaceSymbolShape} into a {@link ContractInterface} for\n * {@link SurfaceSymbol} — a guard, coercing parser, JSON Schema, and seeded\n * generator from one shape declaration (AGENTS §14).\n *\n * @returns A `SurfaceSymbol` contract bundling `schema` / `is` / `parse` / `generate`\n *\n * @example\n * ```ts\n * import { createSurfaceSymbolContract } from '@orkestrel/guide/core'\n *\n * const surfaceSymbol = createSurfaceSymbolContract()\n * surfaceSymbol.is({ name: 'Markdown', kind: 'class' }) // true\n * ```\n */\nexport function createSurfaceSymbolContract(): ContractInterface<SurfaceSymbol> {\n\treturn createContract(surfaceSymbolShape)\n}\n\n/**\n * Compile the {@link methodGroupShape} into a {@link ContractInterface} for\n * {@link MethodGroup} — a guard, coercing parser, JSON Schema, and seeded\n * generator from one shape declaration (AGENTS §14).\n *\n * @returns A `MethodGroup` contract bundling `schema` / `is` / `parse` / `generate`\n *\n * @example\n * ```ts\n * import { createMethodGroupContract } from '@orkestrel/guide/core'\n *\n * const methodGroup = createMethodGroupContract()\n * methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true\n * ```\n */\nexport function createMethodGroupContract(): ContractInterface<MethodGroup> {\n\treturn createContract(methodGroupShape)\n}\n\n/**\n * Compile the {@link manifestEntryShape} into a {@link ContractInterface} for\n * {@link ManifestEntry} — a guard, coercing parser, JSON Schema, and seeded\n * generator from one shape declaration (AGENTS §14).\n *\n * @returns A `ManifestEntry` contract bundling `schema` / `is` / `parse` / `generate`\n *\n * @example\n * ```ts\n * import { createManifestEntryContract } from '@orkestrel/guide/core'\n *\n * const manifestEntry = createManifestEntryContract()\n * manifestEntry.is({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true\n * ```\n */\nexport function createManifestEntryContract(): ContractInterface<ManifestEntry> {\n\treturn createContract(manifestEntryShape)\n}\n"],"mappings":";;;;;;AAGA,IAAa,UAAkB;;;;AAK/B,IAAa,UAAkB;;;;AAK/B,IAAa,QAAgB;;;;AAK7B,IAAa,WAAmB;;;;;;AAOhC,IAAa,mBAAsC,OAAO,OAAO;CAChE;CACA;CACA;CACA;AACD,CAAC;;;;;;;;;;;;;;;;ACND,SAAgB,WAAW,QAAwC;CAClE,OAAO,OAAO,WAAW,WAAW,CAAC,MAAM,IAAI;AAChD;;;;;;;;;;;;;;;AAgBA,SAAgB,WACf,OACA,QACoB;CACpB,MAAM,OAAO,WAAW,MAAM;CAC9B,MAAM,OAAiB,CAAC;CAExB,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,IAAI,CAAC,IAAI,SAAS,KAAK,GAAG;EAC1B,IAAI,IAAI,SAAS,UAAU,GAAG;EAE9B,MAAM,MAAM,KAAK,MAAM,cAAc,IAAI,WAAW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1B;;;;;;;;;;;;;;;;AAiBA,SAAgB,8BAAgE;CAC/E,OAAO,eAAe,kBAAkB;AACzC;;;;;;;;;;;;;;;;AAiBA,SAAgB,4BAA4D;CAC3E,OAAO,eAAe,gBAAgB;AACvC;;;;;;;;;;;;;;;;AAiBA,SAAgB,8BAAgE;CAC/E,OAAO,eAAe,kBAAkB;AACzC"}
@@ -0,0 +1,218 @@
1
+ import type { BlockNode, MarkdownDocument } from '@orkestrel/markdown';
2
+ import type { DeclarationHead, ManifestEntry, MethodGroup, SurfaceSymbol } from './types.js';
3
+ /**
4
+ * The module-scope exports declared in one file's source text — matches
5
+ * `export (async)? (function(\*)?|class|const|interface|type) Name`, deduped
6
+ * by (kind, name). A generator export (`export function* walk`) scans as kind
7
+ * `function` — its trailing `*` is stripped before the {@link ExportKind} check.
8
+ *
9
+ * @param source - The file's source text
10
+ * @returns The file's exported symbols, in file order
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * exportsFrom('export class Markdown {}\n') // [{ name: 'Markdown', kind: 'class' }]
15
+ * exportsFrom('export function* walk() {}\n') // [{ name: 'walk', kind: 'function' }]
16
+ * ```
17
+ */
18
+ export declare function exportsFrom(source: string): readonly SurfaceSymbol[];
19
+ /**
20
+ * The module-scope declarations LACKING the `export` keyword in one file's
21
+ * source text — the mirror image of {@link exportsFrom}'s grammar, anchored
22
+ * the same way (column 0, so an indented inner declaration never matches).
23
+ * Scans only the five {@link ExportKind} keywords (`function` / `class` /
24
+ * `const` / `interface` / `type`) — a module-scope `let` or `var` is a
25
+ * different violation class (AGENTS §1 bans `var`; a bare `let` is not a
26
+ * declaration kind this scanner's five-kind grammar covers) and is out of
27
+ * this check's contract.
28
+ *
29
+ * @param source - The file's source text
30
+ * @returns The file's hidden (non-exported) symbols, in file order
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * hiddenFrom('function secretHelper() {}\n') // [{ name: 'secretHelper', kind: 'function' }]
35
+ * hiddenFrom('export class X {}\n') // []
36
+ * ```
37
+ */
38
+ export declare function hiddenFrom(source: string): readonly SurfaceSymbol[];
39
+ /**
40
+ * Join the declaration head starting at `start` into one space-separated
41
+ * line, consuming lines until the first that ends with `{`.
42
+ *
43
+ * @param lines - The file's source lines
44
+ * @param start - The index of the head's first line
45
+ * @returns The joined head, or `undefined` when no line opens a body
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
50
+ * ```
51
+ */
52
+ export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
53
+ /**
54
+ * The body lines of the named `export class` / `export interface` declaration
55
+ * within one file's source text — everything between the head's opening `{`
56
+ * and the column-0 closing `}`.
57
+ *
58
+ * @param source - The file's source text to search
59
+ * @param keyword - Whether to look for a `class` or an `interface`
60
+ * @param name - The declaration's identifier
61
+ * @returns The declaration's body lines, or an empty array when `source` does not declare it
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * declarationBody('export interface X {\n\twalk(): void\n}\n', 'interface', 'X') // ['\twalk(): void']
66
+ * ```
67
+ */
68
+ export declare function declarationBody(source: string, keyword: 'class' | 'interface', name: string): readonly string[];
69
+ /**
70
+ * The member lines declaring a callable member: plain, `async`, generator
71
+ * (`*`), and optional (`records?(`) methods all count; getters, setters,
72
+ * `static` members, and `#` privates never do (their keyword or `#` breaks
73
+ * the `name(` shape).
74
+ *
75
+ * @param lines - A declaration's body lines
76
+ * @returns The declared method names, deduped and sorted
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * memberMethods(['\tmap(): void', '\tfilter(): void']) // ['filter', 'map']
81
+ * ```
82
+ */
83
+ export declare function memberMethods(lines: readonly string[]): readonly string[];
84
+ /**
85
+ * The block nodes under the named `##` heading, up to the next `##`-or-higher
86
+ * heading (or the document's end) — the section-scoping window `extractSurface` /
87
+ * `extractMethods` walk over.
88
+ *
89
+ * @param document - The parsed guide document
90
+ * @param heading - The `##` heading text to scope to (e.g. `Surface`)
91
+ * @returns The blocks belonging to that section, in document order
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * sectionBlocks(document, 'Surface') // the blocks between `## Surface` and the next `##`
96
+ * ```
97
+ */
98
+ export declare function sectionBlocks(document: MarkdownDocument, heading: string): readonly BlockNode[];
99
+ /**
100
+ * Every `## Surface` identifier the guide documents — each table row's column 0
101
+ * code span (the name) paired with its `Kind` column (located by header text)
102
+ * UNION every backticked H3 entity heading in the section
103
+ * (`{name: <codeSpan>, kind: 'class'}`), deduped by {@link symbolKey}. A row with
104
+ * no code-span name, or an unrecognized `Kind` text, is skipped.
105
+ *
106
+ * @param document - The parsed guide document
107
+ * @returns The documented surface, in encounter order
108
+ *
109
+ * @example
110
+ * ```ts
111
+ * extractSurface(document) // [{ name: 'Markdown', kind: 'class' }, ...]
112
+ * ```
113
+ */
114
+ export declare function extractSurface(document: MarkdownDocument): readonly SurfaceSymbol[];
115
+ /**
116
+ * One {@link MethodGroup} per documented behavioral interface in `## Methods` —
117
+ * an H4 with a code span sets the current interface, and the table immediately
118
+ * following becomes its documented methods.
119
+ *
120
+ * @param document - The parsed guide document
121
+ * @returns The documented method groups, in document order
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * extractMethods(document) // [{ interface: 'MarkdownInterface', methods: ['walk', ...] }]
126
+ * ```
127
+ */
128
+ export declare function extractMethods(document: MarkdownDocument): readonly MethodGroup[];
129
+ /**
130
+ * Every link href in the guide document, including table cells — a full,
131
+ * depth-first walk of the whole AST.
132
+ *
133
+ * @param document - The parsed guide document
134
+ * @returns Every link's href, in walk order
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * extractLinks(document) // ['../../src/core/helpers.ts', 'https://example.com']
139
+ * ```
140
+ */
141
+ export declare function extractLinks(document: MarkdownDocument): readonly string[];
142
+ /**
143
+ * The relative test links declared under `## Tests` — every link href found
144
+ * within that section only.
145
+ *
146
+ * @param document - The parsed guide document
147
+ * @returns The `## Tests` section's link hrefs, in walk order
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * extractTests(document) // ['../../tests/src/core/Markdown.test.ts', ...]
152
+ * ```
153
+ */
154
+ export declare function extractTests(document: MarkdownDocument): readonly string[];
155
+ /**
156
+ * The exported functions in one file's source text whose immediately preceding
157
+ * JSDoc block carries `@example` — walked line by line, tracking the current
158
+ * comment block; the block resets on any non-comment, non-export line so an
159
+ * `@example` never attaches to a declaration it does not directly precede.
160
+ *
161
+ * @param source - The file's source text
162
+ * @returns The exported function names with an `@example`, in file order
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * const block = ['/**', ' * @example', ' *' + '/', 'export function walk() {}', ''].join('\n')
167
+ * examplesFrom(block) // ['walk']
168
+ * examplesFrom('export function walk() {}\n') // []
169
+ * ```
170
+ */
171
+ export declare function examplesFrom(source: string): readonly string[];
172
+ /**
173
+ * The callable-member names in a declaration body (per {@link memberMethods}'
174
+ * grammar) whose immediately preceding JSDoc block, within the same body,
175
+ * carries `@example` — the member-level mirror of {@link examplesFrom}.
176
+ *
177
+ * @param lines - A declaration's body lines
178
+ * @returns The exemplified member names, deduped and sorted
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * exampleMethods(['\t/**', '\t * @example', '\t *' + '/', '\twalk(): void']) // ['walk']
183
+ * ```
184
+ */
185
+ export declare function exampleMethods(lines: readonly string[]): readonly string[];
186
+ /**
187
+ * Every ```ts fenced code block's body text anywhere in the guide document —
188
+ * a full AST walk so a fence nested inside a blockquote or list still counts.
189
+ *
190
+ * @param document - The parsed guide document
191
+ * @returns Every `ts`-lang fence's verbatim code, in walk order
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * extractPatterns(document) // ["import { X } from './x.js'\nX()"]
196
+ * ```
197
+ */
198
+ export declare function extractPatterns(document: MarkdownDocument): readonly string[];
199
+ /**
200
+ * Parse a `## By concept` manifest table into its {@link ManifestEntry} rows —
201
+ * each row's Concept cell (flattened text), Spec / Tests cells (a single link
202
+ * href, resolved against `base`), and Source cell (every link href, resolved
203
+ * against `base`; one directory collapses to a `string`, several become a
204
+ * `readonly string[]`). A row missing a concept, spec link, tests link, or
205
+ * source link is skipped as malformed.
206
+ *
207
+ * @param markdown - The manifest markdown source (e.g. `guides/README.md`'s content)
208
+ * @param base - A single directory name relative to the workspace root that the manifest's
209
+ * links are resolved against (e.g. `'guides'`) — {@link resolveLink}'s arithmetic supports
210
+ * only one path segment, so a deeper or nested base is not supported
211
+ * @returns The manifest's entries, in row order
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * parseManifest(readme, 'guides') // [{ concept: 'Markdown', spec: 'guides/src/markdown.md', ... }]
216
+ * ```
217
+ */
218
+ export declare function parseManifest(markdown: string, base: string): readonly ManifestEntry[];
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The shape of a {@link SurfaceSymbol} — a documented / exported symbol's
3
+ * `name` paired with its {@link ExportKind}.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { createContract } from '@orkestrel/contract'
8
+ * import { surfaceSymbolShape } from '@orkestrel/guide/core'
9
+ *
10
+ * const surfaceSymbol = createContract(surfaceSymbolShape)
11
+ * surfaceSymbol.is({ name: 'Markdown', kind: 'class' }) // true
12
+ * ```
13
+ */
14
+ export declare const surfaceSymbolShape: import("@orkestrel/contract").ObjectShape<{
15
+ name: import("@orkestrel/contract").StringShape;
16
+ kind: import("@orkestrel/contract").LiteralShape<readonly ["type", "interface", "const", "function", "class"]>;
17
+ }>;
18
+ /**
19
+ * The shape of a {@link MethodGroup} — a backticked `interface` name paired
20
+ * with its documented `methods`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createContract } from '@orkestrel/contract'
25
+ * import { methodGroupShape } from '@orkestrel/guide/core'
26
+ *
27
+ * const methodGroup = createContract(methodGroupShape)
28
+ * methodGroup.is({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
29
+ * ```
30
+ */
31
+ export declare const methodGroupShape: import("@orkestrel/contract").ObjectShape<{
32
+ interface: import("@orkestrel/contract").StringShape;
33
+ methods: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>;
34
+ }>;
35
+ /**
36
+ * The shape of a {@link ManifestEntry} — one `## By concept` manifest row,
37
+ * `source` accepting either a single directory or several.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { createContract } from '@orkestrel/contract'
42
+ * import { manifestEntryShape } from '@orkestrel/guide/core'
43
+ *
44
+ * const manifestEntry = createContract(manifestEntryShape)
45
+ * manifestEntry.is({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
46
+ * ```
47
+ */
48
+ export declare const manifestEntryShape: import("@orkestrel/contract").ObjectShape<{
49
+ concept: import("@orkestrel/contract").StringShape;
50
+ spec: import("@orkestrel/contract").StringShape;
51
+ source: import("@orkestrel/contract").UnionShape<[import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>]>;
52
+ tests: import("@orkestrel/contract").StringShape;
53
+ }>;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * The declaration kind a documented / exported symbol carries — the half of the
3
+ * bijection key (alongside its name) a `## Surface` table's `Kind` column encodes.
4
+ */
5
+ export type ExportKind = 'type' | 'interface' | 'const' | 'function' | 'class';
6
+ /**
7
+ * One documented / exported symbol — its identifier plus its declaration kind.
8
+ */
9
+ export interface SurfaceSymbol {
10
+ /** Its identifier. */
11
+ readonly name: string;
12
+ /** Its declaration kind — half of the bijection key alongside {@link name}. */
13
+ readonly kind: ExportKind;
14
+ }
15
+ /**
16
+ * The source scope a guide's manifest entry covers — one module directory, or
17
+ * several when a layer guide spans multiple source directories (a core module
18
+ * plus its backend implementations).
19
+ */
20
+ export type GuideModule = string | readonly string[];
21
+ /**
22
+ * One `## By concept` manifest row — a single guides-parity check target, paths
23
+ * normalized to workspace root.
24
+ */
25
+ export interface ManifestEntry {
26
+ /** The concept name — the row's first cell, flattened. */
27
+ readonly concept: string;
28
+ /** The guide `.md` this entry documents, root-relative. */
29
+ readonly spec: string;
30
+ /** The source directory (or directories) the guide documents. */
31
+ readonly source: GuideModule;
32
+ /** The tests directory the guide's `## Tests` links resolve against. */
33
+ readonly tests: string;
34
+ }
35
+ /**
36
+ * One `#### \`Interface\`` block in a guide's `## Methods` section — the
37
+ * documented member names of one behavioral interface.
38
+ */
39
+ export interface MethodGroup {
40
+ /** The backticked interface name. */
41
+ readonly interface: string;
42
+ /** Its documented Method-cell identifiers, in table order. */
43
+ readonly methods: readonly string[];
44
+ }
45
+ /**
46
+ * The structured, pure view of one parsed guide — every projection extracted and
47
+ * cached once at construction (see {@link createGuide}).
48
+ */
49
+ export interface GuideInterface {
50
+ /** The `##` heading names, in document order — the non-vacuousness guard for section presence. */
51
+ sections(): readonly string[];
52
+ /** Every `## Surface` identifier + kind — table rows union backticked entity headings. */
53
+ surface(): readonly SurfaceSymbol[];
54
+ /** One {@link MethodGroup} per documented behavioral interface in `## Methods`. */
55
+ methods(): readonly MethodGroup[];
56
+ /**
57
+ * Every link href in the guide, including table cells.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * guide.links() // ['../../src/core/helpers.ts']
62
+ * ```
63
+ */
64
+ links(): readonly string[];
65
+ /**
66
+ * The relative test links declared under `## Tests`.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * guide.tests() // ['../../tests/src/core/Guide.test.ts']
71
+ * ```
72
+ */
73
+ tests(): readonly string[];
74
+ /**
75
+ * Every fenced `ts` code block's body text, whole document.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * guide.patterns() // ["import { createGuide } from '@orkestrel/guide'"]
80
+ * ```
81
+ */
82
+ patterns(): readonly string[];
83
+ }
84
+ /**
85
+ * The reflected source truth a guide's documented surface is checked against —
86
+ * a pure view over a consumer-supplied file inventory (see {@link Source}).
87
+ */
88
+ export interface SourceInterface {
89
+ /** Every module-scope export, including type-only, by (name, kind). */
90
+ exports(): readonly SurfaceSymbol[];
91
+ /** The call-signature members of the `class` / `interface` named `name`. */
92
+ methods(name: string): readonly string[];
93
+ /** Whether a workspace-root-relative path exists in the inventory. */
94
+ exists(relative: string): boolean;
95
+ /**
96
+ * Every module-scope declaration LACKING the `export` keyword (AGENTS §5's
97
+ * export-discipline reflection) — empty on a conforming module.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * source.hidden() // []
102
+ * ```
103
+ */
104
+ hidden(): readonly SurfaceSymbol[];
105
+ /**
106
+ * The names of every exported function whose preceding JSDoc carries `@example`.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * source.examples() // ['createGuide', 'createSource']
111
+ * ```
112
+ */
113
+ examples(): readonly string[];
114
+ /**
115
+ * The members of the `class` / `interface` named `name` whose preceding JSDoc,
116
+ * within the declaration body, carries `@example`.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * source.examples('GuideInterface') // ['links', 'tests', 'patterns']
121
+ * ```
122
+ */
123
+ examples(name: string): readonly string[];
124
+ }
125
+ /**
126
+ * The construction input for a {@link Source} — a consumer-supplied file
127
+ * inventory (root-relative path → file text) plus the module scope to
128
+ * reflect. The consumer gathers `files` however their environment allows
129
+ * (`node:fs` in a Node script, `import.meta.glob` in a browser/vitest run) —
130
+ * `Source` itself never touches disk.
131
+ */
132
+ export interface SourceOptions {
133
+ /** The workspace's file inventory, root-relative path → file text. */
134
+ readonly files: Readonly<Record<string, string>>;
135
+ /** The source directory (or directories) this guide documents, root-relative. */
136
+ readonly module: GuideModule;
137
+ }
138
+ /**
139
+ * A declaration head joined into a single line, plus the index of the line
140
+ * carrying its opening `{` — how a head that oxfmt wrapped across lines
141
+ * (printWidth 100) is matched as if it were written on one.
142
+ */
143
+ export interface DeclarationHead {
144
+ /** The joined, space-separated head text. */
145
+ readonly text: string;
146
+ /** The index (within the source `lines`) of the line ending in `{`. */
147
+ readonly end: number;
148
+ }
@@ -0,0 +1,58 @@
1
+ import type { Guard } from '@orkestrel/contract';
2
+ import type { ExportKind, ManifestEntry, MethodGroup, SurfaceSymbol } from './types.js';
3
+ /**
4
+ * Whether `value` is one of the five documented {@link ExportKind} literals — the
5
+ * guard behind extracting a Surface table's `Kind` cell into a typed symbol.
6
+ *
7
+ * @param value - The candidate value
8
+ * @returns `true` when `value` is a valid {@link ExportKind}
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * isExportKind('class') // true
13
+ * isExportKind('enum') // false
14
+ * ```
15
+ */
16
+ export declare const isExportKind: Guard<ExportKind>;
17
+ /**
18
+ * Whether `value` is a well-formed {@link SurfaceSymbol} — a `name` string
19
+ * paired with a valid {@link ExportKind}.
20
+ *
21
+ * @param value - The value to test
22
+ * @returns `true` when `value` is a well-formed {@link SurfaceSymbol}
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * isSurfaceSymbol({ name: 'Markdown', kind: 'class' }) // true
27
+ * isSurfaceSymbol({ name: 'Markdown', kind: 'enum' }) // false
28
+ * ```
29
+ */
30
+ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
31
+ /**
32
+ * Whether `value` is a well-formed {@link MethodGroup} — a backticked
33
+ * `interface` name paired with its documented `methods`.
34
+ *
35
+ * @param value - The value to test
36
+ * @returns `true` when `value` is a well-formed {@link MethodGroup}
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * isMethodGroup({ interface: 'MarkdownInterface', methods: ['walk'] }) // true
41
+ * isMethodGroup({ interface: 'MarkdownInterface', methods: [1] }) // false
42
+ * ```
43
+ */
44
+ export declare const isMethodGroup: Guard<MethodGroup>;
45
+ /**
46
+ * Whether `value` is a well-formed {@link ManifestEntry} — a `## By concept`
47
+ * manifest row, its `source` accepting either a single directory or several.
48
+ *
49
+ * @param value - The value to test
50
+ * @returns `true` when `value` is a well-formed {@link ManifestEntry}
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * isManifestEntry({ concept: 'Markdown', spec: 'guides/src/markdown.md', source: 'src/core', tests: 'tests/src/core' }) // true
55
+ * isManifestEntry({ concept: 1 }) // false
56
+ * ```
57
+ */
58
+ export declare const isManifestEntry: Guard<ManifestEntry>;