/** * Generic markdown + YAML frontmatter splitter. * * Claude Code skill, subagent, command, and output-style files all * follow the same layout: * * ```markdown * --- * name: my-thing * description: Does something useful * --- * * The rest of the file is the body… * ``` * * This module exposes `parse(source)` for raw strings and * `parseFile(path)` for reading from disk. Both return the raw * `frontmatter` (as `unknown` — YAML-decoded but not schema-checked) * plus the markdown `body`. The body is intentionally opaque: Claude * Code resolves `$ARGUMENTS`, named arguments, `${CLAUDE_*}` variables, * `@file`, and shell-substitution forms at invocation time. Schema * validation happens in the per-file-type modules (`Skill.ts`, * `Subagent.ts`, etc.). * * @since 0.1.0 */ import * as Effect from 'effect/Effect'; import * as FileSystem from 'effect/FileSystem'; import { FrontmatterDecodeError, FrontmatterParseError, FrontmatterReadError } from '../Errors.js'; import { CommandFrontmatter } from './Command.js'; import { OutputStyleFrontmatter } from './OutputStyle.js'; import { SkillFrontmatter } from './Skill.js'; import { SubagentFrontmatter } from './Subagent.js'; /** * The result of splitting a markdown file into its YAML frontmatter * and its body. The `frontmatter` is the YAML-decoded value — a plain * JavaScript object, typed as `unknown` so callers must validate it * against a schema before using its fields. * * @category Models * @since 0.1.0 */ export interface ParsedFrontmatter { readonly frontmatter: unknown; readonly body: string; } /** * A parsed markdown file whose frontmatter has been validated against a * concrete schema. * * @category Models * @since 0.1.0 */ export interface DecodedFrontmatter { readonly frontmatter: TFrontmatter; readonly body: string; } /** * Parse a raw markdown string into its frontmatter and body. * * If the source has no `---` delimiters, `frontmatter` is * `undefined` and `body` is the whole source verbatim. If the * delimiters are present but the YAML fails to parse, a * `FrontmatterParseError` is raised. * * The `path` argument is used only for error reporting — pass a * sentinel like `""` if the source didn't come from a file. * * @category Parser * @since 0.1.0 * @example * ```ts * import * as Effect from 'effect/Effect' * import { Frontmatter } from 'effect-claudecode' * * const program = Effect.gen(function* () { * const { frontmatter, body } = yield* Frontmatter.parse( * '---\nname: greet\n---\n\nSay hello.\n', * '' * ) * // frontmatter: { name: 'greet' } * // body: '\nSay hello.\n' * }) * ``` */ export declare const parse: (source: string, path: string) => Effect.Effect; /** * Read a markdown file from disk and parse its frontmatter. Requires * a `FileSystem` service. * * Produces `FrontmatterReadError` if the file cannot be read and * `FrontmatterParseError` if the YAML block is malformed. * * @category Parser * @since 0.1.0 * @example * ```ts * import * as Effect from 'effect/Effect' * import { NodeFileSystem } from '@effect/platform-node-shared/NodeFileSystem' * import { Frontmatter } from 'effect-claudecode' * * const program = Frontmatter.parseFile('./skills/my-skill/SKILL.md').pipe( * Effect.provide(NodeFileSystem.layer) * ) * ``` */ export declare const parseFile: (path: string) => Effect.Effect; /** * Read and decode a `SKILL.md` file in one step. * * @category Parser * @since 0.1.0 */ export declare const parseSkillFile: (path: string) => Effect.Effect, FrontmatterReadError | FrontmatterParseError | FrontmatterDecodeError, FileSystem.FileSystem>; /** * Read and decode a slash-command markdown file in one step. * * @category Parser * @since 0.1.0 */ export declare const parseCommandFile: (path: string) => Effect.Effect, FrontmatterReadError | FrontmatterParseError | FrontmatterDecodeError, FileSystem.FileSystem>; /** * Read and decode a subagent markdown file in one step. * * @category Parser * @since 0.1.0 */ export declare const parseSubagentFile: (path: string) => Effect.Effect, FrontmatterReadError | FrontmatterParseError | FrontmatterDecodeError, FileSystem.FileSystem>; /** * Read and decode an output-style markdown file in one step. * * @category Parser * @since 0.1.0 */ export declare const parseOutputStyleFile: (path: string) => Effect.Effect, FrontmatterReadError | FrontmatterParseError | FrontmatterDecodeError, FileSystem.FileSystem>; //# sourceMappingURL=Parser.d.ts.map