Skip to main content

Interface: ArtifactParser

Defined in: packages/core/src/application/ports/artifact-parser.ts:322

Domain port that abstracts all file-type-specific parsing, delta application, and serialization. Each supported file format has a corresponding infrastructure adapter implementing this port.

Injected at the application layer — domain services never reference concrete parsers directly.

Properties​

fileExtensions​

readonly fileExtensions: readonly string[]

Defined in: packages/core/src/application/ports/artifact-parser.ts:324

File extensions this adapter handles, e.g. ['.md'] or ['.json'].

Methods​

apply()​

apply(ast, delta): DeltaApplicationResult

Defined in: packages/core/src/application/ports/artifact-parser.ts:335

Applies a sequence of delta entries to an AST. All selectors are resolved before any operation is applied — if any selector fails to resolve (no match or ambiguous match), the entire application is rejected with DeltaApplicationError.

Parameters​

ast​

ArtifactAST

delta​

readonly DeltaEntry[]

Returns​

DeltaApplicationResult


deltaInstructions()​

deltaInstructions(): string

Defined in: packages/core/src/application/ports/artifact-parser.ts:368

Returns a format-specific static text block that CompileContext injects verbatim when delta: true is active for the artifact.

Returns​

string


nodeTypes()​

nodeTypes(): readonly NodeTypeDescriptor[]

Defined in: packages/core/src/application/ports/artifact-parser.ts:348

Returns a static description of all addressable node types for this format.

Returns​

readonly NodeTypeDescriptor[]


outline()​

outline(ast, options?): readonly OutlineEntry[]

Defined in: packages/core/src/application/ports/artifact-parser.ts:354

Returns a simplified navigable summary of the artifact's addressable nodes. CompileContext injects this outline when asking the LLM to generate a delta.

Parameters​

ast​

ArtifactAST

options?​

OutlineOptions

Returns​

readonly OutlineEntry[]


parse()​

parse(content): ArtifactAST

Defined in: packages/core/src/application/ports/artifact-parser.ts:327

Parses artifact content into a normalized AST.

Parameters​

content​

string

Returns​

ArtifactAST


parseDelta()​

parseDelta(content): readonly DeltaEntry[]

Defined in: packages/core/src/application/ports/artifact-parser.ts:378

Parses a YAML delta file's raw content into a typed array of delta entries.

Called by ValidateArtifacts on the YAML adapter to convert the raw delta file into DeltaEntry[] before passing them to apply(). Only the YAML adapter is expected to return a non-empty result — other adapters may return an empty array.

Parameters​

content​

string

Returns​

readonly DeltaEntry[]


renderSubtree()​

renderSubtree(node): string

Defined in: packages/core/src/application/ports/artifact-parser.ts:345

Serializes a single AST node and all its descendants back to the artifact's native format string. Used by ValidateArtifacts to evaluate contentMatches and by the metadata extraction engine to extract spec content.

Parameters​

node​

ArtifactNode

Returns​

string


selectorHints()​

selectorHints(outline): Readonly<Record<string, SelectorHintPlaceholders>>

Defined in: packages/core/src/application/ports/artifact-parser.ts:360

Returns root-level selector hint placeholders keyed by node type for the outline entries returned by outline(...).

Parameters​

outline​

readonly OutlineEntry[]

Returns​

Readonly<Record<string, SelectorHintPlaceholders>>


serialize()​

serialize(ast): string

Defined in: packages/core/src/application/ports/artifact-parser.ts:338

Serializes an AST back to the artifact's native format string.

Parameters​

ast​

ArtifactAST

Returns​

string