@orkestrel/scaffold 0.0.115 → 0.0.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/main.js +138 -16
- package/dist/bin/main.js.map +1 -1
- package/dist/host/agents/skills/orkestrel-publish/references/wave.md +1 -1
- package/dist/host/claude/agents/orkestrel.md +2 -2
- package/dist/host/claude/rules/names.md +3 -1
- package/dist/host/guides/abort.md +17 -17
- package/dist/host/guides/agent.md +445 -445
- package/dist/host/guides/brief.md +143 -143
- package/dist/host/guides/browser.md +731 -731
- package/dist/host/guides/budget.md +39 -39
- package/dist/host/guides/capture.md +298 -298
- package/dist/host/guides/console.md +109 -109
- package/dist/host/guides/contract.md +335 -335
- package/dist/host/guides/csv.md +30 -30
- package/dist/host/guides/database.md +163 -163
- package/dist/host/guides/emitter.md +17 -17
- package/dist/host/guides/form.md +99 -99
- package/dist/host/guides/guide.md +368 -183
- package/dist/host/guides/html.md +49 -49
- package/dist/host/guides/indexeddb.md +40 -40
- package/dist/host/guides/interpret.md +139 -139
- package/dist/host/guides/lsp.md +114 -114
- package/dist/host/guides/markdown.md +68 -68
- package/dist/host/guides/mcp.md +3745 -3745
- package/dist/host/guides/middleware.md +170 -170
- package/dist/host/guides/msg.md +95 -95
- package/dist/host/guides/ndjson.md +8 -8
- package/dist/host/guides/ollama.md +56 -56
- package/dist/host/guides/pool.md +21 -21
- package/dist/host/guides/probe.md +82 -82
- package/dist/host/guides/process.md +99 -99
- package/dist/host/guides/program.md +98 -96
- package/dist/host/guides/qualifier.md +70 -70
- package/dist/host/guides/queue.md +37 -37
- package/dist/host/guides/rater.md +38 -38
- package/dist/host/guides/reason.md +308 -308
- package/dist/host/guides/relation.md +50 -50
- package/dist/host/guides/router.md +58 -58
- package/dist/host/guides/scaffold.md +558 -419
- package/dist/host/guides/sea.md +128 -128
- package/dist/host/guides/server.md +100 -100
- package/dist/host/guides/sqlite.md +28 -28
- package/dist/host/guides/sse.md +20 -20
- package/dist/host/guides/study.md +444 -444
- package/dist/host/guides/table.md +82 -82
- package/dist/host/guides/template.md +41 -41
- package/dist/host/guides/terminal.md +121 -121
- package/dist/host/guides/test.md +273 -273
- package/dist/host/guides/timeout.md +18 -18
- package/dist/host/guides/tool.md +27 -27
- package/dist/host/guides/toolbox.md +166 -166
- package/dist/host/guides/websocket.md +54 -54
- package/dist/host/guides/worker.md +24 -24
- package/dist/host/guides/workflow.md +187 -187
- package/dist/host/guides/workspace.md +55 -55
- package/dist/host/manifest.json +55 -55
- package/dist/host/tests/setupPolicy.ts +5 -3
- package/dist/src/core/index.cjs +90 -4
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +229 -144
- package/dist/src/core/index.d.ts +229 -144
- package/dist/src/core/index.js +88 -5
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +295 -66
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +193 -6
- package/dist/src/server/index.d.ts +193 -6
- package/dist/src/server/index.js +290 -69
- package/dist/src/server/index.js.map +1 -1
- package/package.json +5 -4
|
@@ -17,7 +17,7 @@ The full node shape and workspace contract, from [`types.ts`](../src/core/types.
|
|
|
17
17
|
|
|
18
18
|
A `Shape` cell holds an interface's data members as bare names in braces, `?` marking an optional member and `plus` introducing its call-signature members, and a type alias's own type literal with a union's arms escaped as `\|`.
|
|
19
19
|
|
|
20
|
-
|
|
|
20
|
+
| Name | Kind | Signature | Summary |
|
|
21
21
|
| --------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
22
22
|
| `TableAlign` | type | `'left' \| 'right' \| 'center'` | Names the horizontal alignment of a GFM table column, as declared by its delimiter row (`:---` left, `---:` right, `:---:` center). A bare `---` delimiter is represented by `null` in `TableNode.align`: the positional array requires one entry per column, JSON cannot carry `undefined` in an array, and the bare delimiter is an explicit no-alignment marker rather than an omitted value. |
|
|
23
23
|
| `ListItemMatch` | interface | `{ ordered, start, content, indent, marker }` | Represents the parsed parts of a single list-item line — the value the block phase's list detector returns for a `-` / `*` / `+` bullet or a `1.` / `1)` ordinal line. |
|
|
@@ -56,11 +56,11 @@ A `Shape` cell holds an interface's data members as bare names in braces, `?` ma
|
|
|
56
56
|
| `MarkdownHandler<TNode, T>` | type | `(node: TNode, children: readonly T[]) => T` | Represents a fold handler for one AST element — receives the node and its children already folded to `T`, and produces the node's own `T`. The building block of a `MarkdownHandlerMap` catamorphism table. |
|
|
57
57
|
| `MarkdownHandlerMap<T>` | interface | `{ document, heading, paragraph, thematicBreak, blockquote, codeBlock, list, listItem, table, text, emphasis, codeSpan, break, link, image }` | Represents the total catamorphism table for `MarkdownInterface.fold` — one `MarkdownHandler` per AST element, keyed by its `element` discriminant. Every key is required: a fold is total over the AST, so there is no element it can skip. |
|
|
58
58
|
| `MarkdownRewriteHandler` | type | `(node: MarkdownNode) => MarkdownNode` | Represents a copy-on-write node rewrite applied bottom-up by `MarkdownInterface.map` — receives one node (its own children already rewritten) and returns its replacement (the same node, unchanged, or a new node). |
|
|
59
|
-
| `MarkdownParseResult` | type | `readonly [document: MarkdownDocument, spans: ReadonlyMap<MarkdownNode, MarkdownSpan>]`
|
|
60
|
-
| `MarkdownDerivation<T>` | type | `readonly [value: T, derivations: ReadonlyMap<MarkdownNode, MarkdownNode \| undefined>]`
|
|
61
|
-
| `MarkdownInterface` | interface | `{ document
|
|
59
|
+
| `MarkdownParseResult` | type | `readonly [ document: MarkdownDocument, spans: ReadonlyMap<MarkdownNode, MarkdownSpan> ]` | Pairs a parsed document with the `MarkdownSpan` of each of its nodes — what `parseProvenance` returns, and what `parseDocument` projects the document out of. |
|
|
60
|
+
| `MarkdownDerivation<T>` | type | `readonly [ value: T, derivations: ReadonlyMap<MarkdownNode, MarkdownNode \| undefined> ]` | Pairs a rewritten value with the input node each rewritten node was produced from — what `rewriteDocument` returns, so provenance survives a rewrite instead of ending at it. `T` is the rewritten value: the document for a whole-document rewrite. |
|
|
61
|
+
| `MarkdownInterface` | interface | `{ document, walk(), find(), filter(), span(), map(), reduce(), fold(), stream() }` | Represents a stateful, parsed markdown document: the typed `MarkdownDocument` AST plus the query, rewrite, and fold operations over it. |
|
|
62
62
|
|
|
63
|
-
|
|
|
63
|
+
| Name | Kind | Signature | Summary |
|
|
64
64
|
| -------------------- | --------- | --------------- | ---------------------------------------------------------------------------- |
|
|
65
65
|
| `MarkdownInlineScan` | interface | `{ node, end }` | Represents an inline construct and the source offset where scanning resumes. |
|
|
66
66
|
|
|
@@ -70,16 +70,16 @@ From [`constants.ts`](../src/core/constants.ts).
|
|
|
70
70
|
|
|
71
71
|
A `Shape` cell holds the constant's declared type.
|
|
72
72
|
|
|
73
|
-
|
|
|
73
|
+
| Name | Kind | Signature | Summary |
|
|
74
74
|
| ------------------ | ----- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
75
|
-
| `MAX_DEPTH` | const | `
|
|
75
|
+
| `MAX_DEPTH` | const | `64` | Caps the recursion depth the parse pipeline (`parseDocument` and its `parsers.ts` helpers), the `helpers.ts` traversal / projection functions (`markdownToHTML`, `renderMarkdown`, `walkNodes`, `foldNode`, `rewriteDocument`), and the `compilers.ts` renderer (`renderHTML`) honor before degrading, at 64. It bounds blockquote nesting, inline nesting (emphasis / links), and traversal / projection recursion so pathological or hostile input cannot exhaust the call stack. `htmlToMarkdown` is the inherited exception: its fold and depth cap belong to `@orkestrel/html`. |
|
|
76
76
|
| `EMPTY_PROJECTION` | const | `MarkdownProjection` | Holds the frozen empty HTML-to-markdown projection from which projection factories default every absent field. |
|
|
77
77
|
|
|
78
78
|
### Parsers
|
|
79
79
|
|
|
80
80
|
The block/inline parsing pipeline, from [`parsers.ts`](../src/core/parsers.ts) — the orchestration `parseDocument` composes out of `helpers.ts`'s pure scanning leaves. `parseBlocks` is the recursive spine; each parser is exported and independently testable. The construct scanners it composes (`collectTable` / `collectList`) are leaves and live in [`helpers.ts`](../src/core/helpers.ts) with the other scanners; each calls back into the phase entry above it, so the two files are mutually recursive by design.
|
|
81
81
|
|
|
82
|
-
|
|
|
82
|
+
| Name | Kind | Signature | Summary |
|
|
83
83
|
| ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
84
84
|
| `parseBlocks` | function | `(lines: readonly MarkdownSource[], depth: number, spans?: Map<MarkdownNode, MarkdownSpan>, end?: number) => readonly BlockNode[]` | Parses a run of markdown lines into a block AST, recursing into nested blockquotes, list items, and depth-capped degrade paragraphs. |
|
|
85
85
|
| `parseDocument` | function | `(markdown: string) => MarkdownDocument` | Parses a markdown string into a typed `MarkdownDocument` AST through the block phase — the document half of what `parseProvenance` returns. Malformed markdown degrades to literal text, so the parse never throws. |
|
|
@@ -90,7 +90,7 @@ The block/inline parsing pipeline, from [`parsers.ts`](../src/core/parsers.ts)
|
|
|
90
90
|
|
|
91
91
|
Pure, total leaves from [`helpers.ts`](../src/core/helpers.ts) — the line and character structural predicates the block and inline phases test raw lines with, the scanning functional core `parsers.ts` composes, the AST-crossing projections (`markdownToHTML`, `renderMarkdown`, `htmlToMarkdown`) plus the projection leaves they are built from, and the traversal engines `Markdown` delegates to. Every function is unit-testable in isolation; malformed input degrades to text, never throws. A predicate over a raw `string` narrows no type, so it is a leaf here rather than a guard in `validators.ts`; `renderHTML` drives the `HTML` class, so it sits in [`compilers.ts`](../src/core/compilers.ts) instead (§ [Compilers](#compilers)). `projectHTMLLeaf`'s leaf parameter is html's own `TextNode`, written `HTMLTextNode` in the signature because this package declares a `TextNode` of its own.
|
|
92
92
|
|
|
93
|
-
|
|
|
93
|
+
| Name | Kind | Signature | Summary |
|
|
94
94
|
| ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
95
95
|
| `splitLines` | function | `(markdown: string) => readonly MarkdownSource[]` | Splits a markdown document into offset-bearing lines while normalizing CRLF and bare CR terminators at the line boundary. A single trailing terminator does not yield a final empty line. |
|
|
96
96
|
| `sliceSource` | function | `(source: MarkdownSource, from: number, to: number) => MarkdownSource` | Slices derived markdown text and narrows each intersecting source segment to the same text-relative range. |
|
|
@@ -113,17 +113,17 @@ Pure, total leaves from [`helpers.ts`](../src/core/helpers.ts) — the line and
|
|
|
113
113
|
| `stripQuote` | function | `(source: MarkdownSource) => MarkdownSource` | Strips one level of blockquote marker (`>` plus one optional following space) from an offset-bearing blockquote line, so the de-quoted source re-parses as nested blocks without losing its original coordinates. |
|
|
114
114
|
| `splitTableRow` | function | `(row: string) => readonly string[]` | Splits one GFM table row into its cell strings — outer pipes are optional, a pipe escaped by a leading backslash inside a cell is not a separator (it becomes a literal pipe character), and the empty leading / trailing cell an outer pipe produces is dropped. Derives the string form from `splitTableSources`, which owns the escaped-pipe splitting rule. |
|
|
115
115
|
| `splitTableSources` | function | `(row: MarkdownSource) => readonly MarkdownSource[]` | Splits an offset-bearing GFM table row into offset-bearing cells, retaining the complete source spelling of an escaped pipe while exposing its literal value. |
|
|
116
|
-
| `delimiterToAlignments` | function | `(delimiter: string) =>
|
|
116
|
+
| `delimiterToAlignments` | function | `(delimiter: string) => ReadonlyArray<TableAlign \| null>` | Derives the per-column `TableAlign` list from a GFM delimiter row — `:---` left, `---:` right, `:---:` center, and `---` as the explicit no-alignment marker represented by `null`. |
|
|
117
117
|
| `startsBlock` | function | `(lines: readonly string[], index: number) => boolean` | Checks whether the line at `index` starts a new block kind (heading / fence / thematic break / blockquote / list / table) — the paragraph collector stops at such a line so a block following a paragraph without a blank line still parses (a trusted-input caller writing a `##` heading directly under a paragraph, with no intervening blank line). |
|
|
118
118
|
| `unescapeText` | function | `(text: string) => string` | Resolves backslash escapes in a raw string to their literal characters — used for a link `href` (which is not otherwise inline-parsed) and any plain text run. |
|
|
119
119
|
| `coalesceText` | function | `(nodes: readonly InlineNode[], spans?: Map<MarkdownNode, MarkdownSpan>) => readonly InlineNode[]` | Merges adjacent text nodes into one — the inline scanner emits a text node per unrecognized character, so coalescing keeps the AST clean and assertion-friendly. |
|
|
120
|
-
| `scanCode` | function | `(source, start, to) => CodeSpanMatch \| undefined`
|
|
121
|
-
| `scanLink` | function | `(source, start, to, depth
|
|
122
|
-
| `scanEmphasis` | function | `(source, start, to, depth
|
|
120
|
+
| `scanCode` | function | `(source: string, start: number, to: number) => CodeSpanMatch \| undefined` | Scans an inline code span at `start` (a \`\` \` \`\`-run … a matching \`\` \` \`\`-run of the same length, the CommonMark rule that lets a span contain backticks). Returns the span's literal text + end index, or \`undefined\` when no matching closer exists (it then degrades to literal backticks). |
|
|
121
|
+
| `scanLink` | function | `(source: string, start: number, to: number, depth?: number) => LinkScan \| undefined` | Scans a link `[text](href)` at `start` — the text runs to a balanced `]`, then `(` must immediately follow and the destination runs to the matching `)` (both respect nested delimiters + escapes) through `locateLink`, and returns the parsed node and end index. Returns `undefined` when the shape does not hold (it then degrades to a literal `[`). |
|
|
122
|
+
| `scanEmphasis` | function | `(source: string, start: number, to: number, depth?: number) => EmphasisScan \| undefined` | Scans an emphasis run at `start` (`*` / `_`, doubled for strong) — finds the nearest matching closing run of the same marker + width while skipping complete nested runs from the other marker family, and requires non-space immediately inside both delimiters (the CommonMark flanking simplification that blocks `* x *`) through `locateEmphasis`, and returns the parsed node and end index. Returns `undefined` when no valid closer exists (it then degrades to a literal marker). |
|
|
123
123
|
| `locateLink` | function | `(source: string, start: number, to: number) => LinkBounds \| undefined` | Locates a link `[text](href)` at `start` — the text runs to a balanced `]`, then `(` must immediately follow and the destination runs to the matching `)` (both respect nested delimiters + escapes). Returns the label close and syntax end, or `undefined` when the shape does not hold (it then degrades to a literal `[`). |
|
|
124
124
|
| `locateEmphasis` | function | `(source: string, start: number, to: number) => EmphasisBounds \| undefined` | Locates an emphasis run at `start` (`*` / `_`, doubled for strong) — finds the nearest matching closing run of the same marker + width while skipping complete nested runs from the other marker family, and requires non-space immediately inside both delimiters (the CommonMark flanking simplification that blocks `* x *`). Returns the content and syntax bounds, or `undefined` when no valid closer exists (it then degrades to a literal marker). |
|
|
125
|
-
| `scanInline` | function | `(source: string, from: number, to: number, depth
|
|
126
|
-
| `scanInlineSource` | function | `(source: MarkdownSource, from: number, to: number, spans: Map<MarkdownNode, MarkdownSpan>, depth
|
|
125
|
+
| `scanInline` | function | `(source: string, from: number, to: number, depth?: number) => readonly InlineNode[]` | Scans the window `[from, to)` of `source` into inline nodes — the single recursive engine the inline phase runs on (emphasis, link text, and image alternative content recurse through it). Linear: each character is consumed once; a failed construct emits its opening character as text and advances by one, so there is no re-scan (no ReDoS). |
|
|
126
|
+
| `scanInlineSource` | function | `(source: MarkdownSource, from: number, to: number, spans: Map<MarkdownNode, MarkdownSpan>, depth?: number) => readonly InlineNode[]` | Scans an offset-bearing inline window with the same engine as `scanInline` and records each emitted node against the original markdown string. |
|
|
127
127
|
| `collectTable` | function | `(lines: readonly MarkdownSource[], start: number, spans?: Map<MarkdownNode, MarkdownSpan>) => TableCollection` | Collects a GFM table starting at a header row, parsing the header, the alignment row, and every contiguous body row that follows. |
|
|
128
128
|
| `collectList` | function | `(lines: readonly MarkdownSource[], start: number, depth: number, spans?: Map<MarkdownNode, MarkdownSpan>, end?: number) => ListCollection` | Collects a list starting at the first item, gathering sibling items at the same indent/ordering and recursing into each item's own block content. |
|
|
129
129
|
| `markdownToHTML` | function | `(node: MarkdownNode) => HTMLDocument` | Projects a `MarkdownNode` into an unsanitized `HTMLDocument`. |
|
|
@@ -144,32 +144,32 @@ Pure, total leaves from [`helpers.ts`](../src/core/helpers.ts) — the line and
|
|
|
144
144
|
|
|
145
145
|
The iterative engines compose these node and scan operations. Child results are supplied in traversal order; span recorders and cell-pair logs belong to the operation that calls them.
|
|
146
146
|
|
|
147
|
-
|
|
|
148
|
-
| ------------------------- | -------- |
|
|
149
|
-
| `projectMarkdownNode` | function | `(current, children) => HTMLNode \| undefined`
|
|
150
|
-
| `renderMarkdownNode` | function | `(current, children, literal, emphasis) => string`
|
|
151
|
-
| `foldMarkdownNode` | function | `<T>(node, handlers
|
|
152
|
-
| `rebuildMarkdownNode` | function | `(current, children) => MarkdownNode`
|
|
153
|
-
| `rebuildMarkdownCell` | function | `(cell, outputs, pairs) => readonly InlineNode[]`
|
|
154
|
-
| `acceptMarkdownNode` | function | `(current, rebuilt, result) => MarkdownNode`
|
|
155
|
-
| `walkMarkdownCharacters` | function | `(source, from, to) => Generator<readonly [number, string], void, unknown>`
|
|
156
|
-
| `countMarkdownRun` | function | `(source, start, to) => number`
|
|
157
|
-
| `findFollowingNode` | function | `(nodes, start) => MarkdownNode \| undefined`
|
|
158
|
-
| `escapeMarkdownText` | function | `(value, bang) => string`
|
|
159
|
-
| `locateMarkdownDelimiter` | function | `(source, start, to, open, close) => number \| undefined`
|
|
160
|
-
| `recordMarkdownText` | function | `(source, value, start, end, spans, nodes) => void`
|
|
161
|
-
| `scanMarkdownInline` | function | `(source, index, to, spans, depth) => MarkdownInlineScan \| undefined`
|
|
162
|
-
| `walkMarkdownLines` | function | `(lines, start) => Generator<number, void, unknown>`
|
|
163
|
-
| `splitTextRuns` | function | `(nodes) => ReadonlyArray<readonly InlineNode[]>`
|
|
164
|
-
| `listChildren` | function | `(node) => readonly MarkdownNode[]`
|
|
165
|
-
| `trimLeading` | function | `(nodes) => readonly InlineNode[]`
|
|
166
|
-
| `trimTrailing` | function | `(nodes) => readonly InlineNode[]`
|
|
147
|
+
| Name | Kind | Signature | Summary |
|
|
148
|
+
| ------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
149
|
+
| `projectMarkdownNode` | function | `(current: MarkdownNode, children: ReadonlyArray<HTMLNode \| undefined>) => HTMLNode \| undefined` | Projects one markdown node from its already projected children. |
|
|
150
|
+
| `renderMarkdownNode` | function | `(current: MarkdownNode, children: readonly string[], literal: string, emphasis: number) => string` | Renders one markdown node from its rendered children and escaped literal text. |
|
|
151
|
+
| `foldMarkdownNode` | function | `<T>(node: MarkdownNode, handlers: MarkdownHandlerMap<T>, children: readonly T[]) => T` | Dispatches one markdown node and its folded children to the matching handler. |
|
|
152
|
+
| `rebuildMarkdownNode` | function | `(current: MarkdownNode, children: readonly MarkdownNode[]) => MarkdownNode` | Rebuilds one markdown node when accepted child replacements change its identity. |
|
|
153
|
+
| `rebuildMarkdownCell` | function | `(cell: readonly InlineNode[], outputs: Iterator<MarkdownNode, undefined>, pairs: Array<readonly [InlineNode, InlineNode]>) => readonly InlineNode[]` | Rebuilds a table cell and records each input and accepted output pair. |
|
|
154
|
+
| `acceptMarkdownNode` | function | `(current: MarkdownNode, rebuilt: MarkdownNode, result: MarkdownNode) => MarkdownNode` | Accepts a rewritten node only when it fits the original node slot. |
|
|
155
|
+
| `walkMarkdownCharacters` | function | `(source: string, from: number, to: number) => Generator<readonly [number, string], void, unknown>` | Yields UTF-16 offsets and characters within a markdown scan window. |
|
|
156
|
+
| `countMarkdownRun` | function | `(source: string, start: number, to: number) => number` | Counts consecutive copies of the character at the start of a scan window. |
|
|
157
|
+
| `findFollowingNode` | function | `(nodes: readonly MarkdownNode[], start: number) => MarkdownNode \| undefined` | Finds the next defined markdown node at or after an array offset. |
|
|
158
|
+
| `escapeMarkdownText` | function | `(value: string, bang: boolean) => string` | Escapes literal text so markdown syntax remains literal when rendered. |
|
|
159
|
+
| `locateMarkdownDelimiter` | function | `(source: string, start: number, to: number, open: string, close: string) => number \| undefined` | Locates a balanced closing delimiter while skipping backslash escapes. |
|
|
160
|
+
| `recordMarkdownText` | function | `(source: MarkdownSource, value: string, start: number, end: number, spans: Map<MarkdownNode, MarkdownSpan>, nodes: InlineNode[]) => void` | Appends a nonempty text node and records its original source span. |
|
|
161
|
+
| `scanMarkdownInline` | function | `(source: MarkdownSource, index: number, to: number, spans: Map<MarkdownNode, MarkdownSpan>, depth: number) => MarkdownInlineScan \| undefined` | Scans one inline construct and records the spans of its nested children. |
|
|
162
|
+
| `walkMarkdownLines` | function | `(lines: readonly MarkdownSource[], start: number) => Generator<number, void, unknown>` | Yields line offsets through a closable markdown scan iterator. |
|
|
163
|
+
| `splitTextRuns` | function | `(nodes: readonly InlineNode[]) => ReadonlyArray<readonly InlineNode[]>` | Splits inline nodes into adjacent text runs and singleton non-text runs. |
|
|
164
|
+
| `listChildren` | function | `(node: MarkdownNode) => readonly MarkdownNode[]` | Lists the direct children of a markdown node in traversal order. |
|
|
165
|
+
| `trimLeading` | function | `(nodes: readonly InlineNode[]) => readonly InlineNode[]` | Trims leading whitespace when an inline run starts with a text node. |
|
|
166
|
+
| `trimTrailing` | function | `(nodes: readonly InlineNode[]) => readonly InlineNode[]` | Trims trailing whitespace when an inline run ends with a text node. |
|
|
167
167
|
|
|
168
168
|
### Compilers
|
|
169
169
|
|
|
170
170
|
From [`compilers.ts`](../src/core/compilers.ts) — the class-driving half of the outbound direction. `helpers.ts` owns the pure `markdownToHTML` projection and imports no implementation class; the compiler below constructs `@orkestrel/html`'s `HTML` class, so it sits above the leaves and consumes them.
|
|
171
171
|
|
|
172
|
-
|
|
|
172
|
+
| Name | Kind | Signature | Summary |
|
|
173
173
|
| ------------ | -------- | -------------------------------- | ----------------------------------------------------- |
|
|
174
174
|
| `renderHTML` | function | `(node: MarkdownNode) => string` | Renders a `MarkdownNode` to sanitized canonical HTML. |
|
|
175
175
|
|
|
@@ -179,15 +179,15 @@ Declarative `ContractShape` values (from `@orkestrel/contract`) from [`shapers.t
|
|
|
179
179
|
|
|
180
180
|
A `Shape` cell holds the constant's declared type.
|
|
181
181
|
|
|
182
|
-
|
|
|
183
|
-
| -------------------- | ----- |
|
|
184
|
-
| `textShape` | const | `ObjectShape<{ element
|
|
185
|
-
| `codeSpanShape` | const | `ObjectShape<{ element
|
|
186
|
-
| `lineBreakShape` | const | `ObjectShape<{ element }>`
|
|
187
|
-
| `codeBlockShape` | const | `ObjectShape<{ element
|
|
188
|
-
| `thematicBreakShape` | const | `ObjectShape<{ element }>`
|
|
189
|
-
| `tableAlignShape` | const | `LiteralShape<
|
|
190
|
-
| `listItemMatchShape` | const | `ObjectShape<{ ordered
|
|
182
|
+
| Name | Kind | Signature | Summary |
|
|
183
|
+
| -------------------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
184
|
+
| `textShape` | const | `import("@orkestrel/contract").ObjectShape<{ element: import("@orkestrel/contract").LiteralShape<readonly ["text"]>; value: import("@orkestrel/contract").StringShape; }, false>` | Describes the shape of a `TextNode` — a plain-text leaf inline run. |
|
|
185
|
+
| `codeSpanShape` | const | `import("@orkestrel/contract").ObjectShape<{ element: import("@orkestrel/contract").LiteralShape<readonly ["codeSpan"]>; value: import("@orkestrel/contract").StringShape; }, false>` | Describes the shape of a `CodeSpanNode` — an inline code span (\`\` \`code\` \`\`). |
|
|
186
|
+
| `lineBreakShape` | const | `import("@orkestrel/contract").ObjectShape<{ element: import("@orkestrel/contract").LiteralShape<readonly ["break"]>; }, false>` | Describes the shape of a `LineBreakNode` — a GFM hard line-break leaf. |
|
|
187
|
+
| `codeBlockShape` | const | `import("@orkestrel/contract").ObjectShape<{ element: import("@orkestrel/contract").LiteralShape<readonly ["codeBlock"]>; lang: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; code: import("@orkestrel/contract").StringShape; }, false>` | Describes the shape of a `CodeBlockNode` — a fenced code block. `lang` is optional (absent when the opening fence carries no info-string). |
|
|
188
|
+
| `thematicBreakShape` | const | `import("@orkestrel/contract").ObjectShape<{ element: import("@orkestrel/contract").LiteralShape<readonly ["thematicBreak"]>; }, false>` | Describes the shape of a `ThematicBreakNode` — a horizontal rule. Carries no fields beyond its `element` discriminant. |
|
|
189
|
+
| `tableAlignShape` | const | `import("@orkestrel/contract").LiteralShape<readonly ["left", "right", "center"]>` | Describes the shape of a `TableAlign` — the per-column GFM table alignment literal. Absence is no member of it, so the shape refuses the `null` a bare `---` delimiter takes in a `TableNode`'s `align` list. |
|
|
190
|
+
| `listItemMatchShape` | const | `import("@orkestrel/contract").ObjectShape<{ ordered: import("@orkestrel/contract").BooleanShape; start: import("@orkestrel/contract").NumberShape; content: import("@orkestrel/contract").StringShape; indent: import("@orkestrel/contract").NumberShape; marker: import("@orkestrel/contract").NumberShape; }, false>` | Describes the shape of `ListItemMatch` — the parsed parts of a single list-item line the block phase's list detector returns. Fully non-recursive (no nested node fields), so every field shapes directly. |
|
|
191
191
|
|
|
192
192
|
### Validators
|
|
193
193
|
|
|
@@ -195,34 +195,34 @@ Node guards, from [`validators.ts`](../src/core/validators.ts). The `is{Element}
|
|
|
195
195
|
|
|
196
196
|
In a guard table a `Shape` cell holds the type the guard narrows to.
|
|
197
197
|
|
|
198
|
-
|
|
|
199
|
-
| --------------------- | -------- |
|
|
200
|
-
| `isHeadingNode` | function | `HeadingNode` | Determines whether a node is a heading block. |
|
|
201
|
-
| `isParagraphNode` | function | `ParagraphNode` | Determines whether a node is a paragraph block. |
|
|
202
|
-
| `isListNode` | function | `ListNode` | Determines whether a node is a list block. |
|
|
203
|
-
| `isTableNode` | function | `TableNode` | Determines whether a node is a GFM table block. |
|
|
204
|
-
| `isCodeBlockNode` | function | `CodeBlockNode` | Determines whether a node is a fenced code block. |
|
|
205
|
-
| `isBlockquoteNode` | function | `BlockquoteNode` | Determines whether a node is a blockquote block. |
|
|
206
|
-
| `isThematicBreakNode` | function | `ThematicBreakNode` | Determines whether a node is a thematic break (horizontal rule) block. |
|
|
207
|
-
| `isTextNode` | function | `TextNode` | Determines whether a node is a plain text run. |
|
|
208
|
-
| `isEmphasisNode` | function | `EmphasisNode` | Determines whether a node is an emphasis run (`*em*` / `**strong**`). |
|
|
209
|
-
| `isCodeSpanNode` | function | `CodeSpanNode` | Determines whether a node is an inline code span. |
|
|
210
|
-
| `isLineBreakNode` | function | `LineBreakNode` | Determines whether a node is a GFM hard line break. |
|
|
211
|
-
| `isLinkNode` | function | `LinkNode` | Determines whether a node is a link. |
|
|
212
|
-
| `isImageNode` | function | `ImageNode` | Determines whether a node is an image. |
|
|
213
|
-
| `isInlineNode` | const | `InlineNode
|
|
214
|
-
| `isBlockNode` | const | `BlockNode
|
|
215
|
-
| `isMarkdownNode` | const | `MarkdownNode
|
|
216
|
-
| `isMarkdownDocument` | const | `MarkdownDocument
|
|
198
|
+
| Name | Kind | Signature | Summary |
|
|
199
|
+
| --------------------- | -------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
200
|
+
| `isHeadingNode` | function | `(node: MarkdownNode) => node is HeadingNode` | Determines whether a node is a heading block. |
|
|
201
|
+
| `isParagraphNode` | function | `(node: MarkdownNode) => node is ParagraphNode` | Determines whether a node is a paragraph block. |
|
|
202
|
+
| `isListNode` | function | `(node: MarkdownNode) => node is ListNode` | Determines whether a node is a list block. |
|
|
203
|
+
| `isTableNode` | function | `(node: MarkdownNode) => node is TableNode` | Determines whether a node is a GFM table block. |
|
|
204
|
+
| `isCodeBlockNode` | function | `(node: MarkdownNode) => node is CodeBlockNode` | Determines whether a node is a fenced code block. |
|
|
205
|
+
| `isBlockquoteNode` | function | `(node: MarkdownNode) => node is BlockquoteNode` | Determines whether a node is a blockquote block. |
|
|
206
|
+
| `isThematicBreakNode` | function | `(node: MarkdownNode) => node is ThematicBreakNode` | Determines whether a node is a thematic break (horizontal rule) block. |
|
|
207
|
+
| `isTextNode` | function | `(node: MarkdownNode) => node is TextNode` | Determines whether a node is a plain text run. |
|
|
208
|
+
| `isEmphasisNode` | function | `(node: MarkdownNode) => node is EmphasisNode` | Determines whether a node is an emphasis run (`*em*` / `**strong**`). |
|
|
209
|
+
| `isCodeSpanNode` | function | `(node: MarkdownNode) => node is CodeSpanNode` | Determines whether a node is an inline code span. |
|
|
210
|
+
| `isLineBreakNode` | function | `(node: MarkdownNode) => node is LineBreakNode` | Determines whether a node is a GFM hard line break. |
|
|
211
|
+
| `isLinkNode` | function | `(node: MarkdownNode) => node is LinkNode` | Determines whether a node is a link. |
|
|
212
|
+
| `isImageNode` | function | `(node: MarkdownNode) => node is ImageNode` | Determines whether a node is an image. |
|
|
213
|
+
| `isInlineNode` | const | `Guard<InlineNode>` | Determines whether an arbitrary value is a valid `InlineNode` — a text run, emphasis, code span, hard break, link, or image, recursively validated. |
|
|
214
|
+
| `isBlockNode` | const | `Guard<BlockNode>` | Determines whether an arbitrary value is a valid `BlockNode` — a heading, paragraph, list, table, code block, blockquote, or thematic break, recursively validated. |
|
|
215
|
+
| `isMarkdownNode` | const | `Guard<MarkdownNode>` | Determines whether an arbitrary value is a valid `MarkdownNode` — the `MarkdownDocument` root, a `BlockNode`, a `ListItemNode`, or an `InlineNode`, recursively validated. |
|
|
216
|
+
| `isMarkdownDocument` | const | `Guard<MarkdownDocument>` | Determines whether an arbitrary value is a valid `MarkdownDocument` — the parsed-AST root `parseDocument` returns, recursively validated. |
|
|
217
217
|
|
|
218
218
|
### Classes
|
|
219
219
|
|
|
220
220
|
The implementing class of `MarkdownInterface`, from [`Markdown.ts`](../src/core/Markdown.ts) —
|
|
221
221
|
documented in full under its own heading following this table.
|
|
222
222
|
|
|
223
|
-
| Name | Kind | Summary |
|
|
224
|
-
| ---------- | ----- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
225
|
-
| `Markdown` | class | Wraps a typed `MarkdownDocument` AST as a stateful, parsed markdown document with the query (`find` / `filter` / `reduce` / iteration), rewrite (`map`), fold, and streaming operations `MarkdownInterface` declares. |
|
|
223
|
+
| Name | Kind | Signature | Summary |
|
|
224
|
+
| ---------- | ----- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
225
|
+
| `Markdown` | class | `new (input: string \| MarkdownDocument) => MarkdownInterface` | Wraps a typed `MarkdownDocument` AST as a stateful, parsed markdown document with the query (`find` / `filter` / `reduce` / iteration), rewrite (`map`), fold, and streaming operations `MarkdownInterface` declares. |
|
|
226
226
|
|
|
227
227
|
### `Markdown`
|
|
228
228
|
|
|
@@ -232,7 +232,7 @@ A stateful, parsed markdown workspace, constructed from a markdown `string` (run
|
|
|
232
232
|
|
|
233
233
|
From [`factories.ts`](../src/core/factories.ts).
|
|
234
234
|
|
|
235
|
-
|
|
|
235
|
+
| Name | Kind | Signature | Summary |
|
|
236
236
|
| ----------------------------- | -------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
237
237
|
| `createMarkdown` | function | `(input: string \| MarkdownDocument) => MarkdownInterface` | Creates a stateful markdown handle from a markdown string or an already-parsed `MarkdownDocument` — a typed AST plus the query, rewrite, and fold operations `MarkdownInterface` exposes. |
|
|
238
238
|
| `createTextContract` | function | `() => ContractInterface<TextNode>` | Compiles the `textShape` into a `ContractInterface` for `TextNode` — a guard, coercing parser, JSON Schema, and seeded generator from one shape declaration. |
|