UNPKG

@felixgeelhaar/cclint

Version:

Catch CLAUDE.md drift before Claude misbehaves. Lints CLAUDE.md, skills, subagents, and hooks for Claude Code projects.

71 lines 2.87 kB
/** * Shared YAML-frontmatter parser for Markdown-based Claude Code config files * (skills, subagents, …). * * @remarks * This is a deliberately small, dependency-free parser that understands the * subset of YAML frontmatter that Claude Code config files use in practice: * a `---`…`---` fenced block containing `key: value` scalars, dash lists, and * inline `[a, b]` arrays. It is a pure domain module — it takes the already * split `lines` of a file and returns a typed {@link Frontmatter} view. It * performs no file or network IO. * * It intentionally handles the edge cases that the previous per-rule * hand-rolled parsers disagreed on: quoted values that contain colons, `#` * comments (full-line and trailing), multiline dash arrays, inline bracket * arrays, and CRLF line endings. */ /** A parsed frontmatter value: either a scalar string or a list of strings. */ type FrontmatterEntry = string | readonly string[]; /** * Immutable, typed view over a parsed frontmatter block. * * Accessor methods interpret the stored raw values so callers never touch * quoting, bracket, or comment syntax directly. */ export declare class Frontmatter { private readonly fields; /** Whether the document contained at least one `---` fence line. */ readonly hasFence: boolean; constructor(fields: ReadonlyMap<string, FrontmatterEntry>, hasFence: boolean); /** Whether a key was present in the frontmatter (even with an empty value). */ has(key: string): boolean; /** * The scalar value for `key`, with surrounding quotes stripped. * * Returns `undefined` if the key is absent or was parsed as an array. * An empty value (`key:` with nothing after it) returns an empty string. */ getString(key: string): string | undefined; /** * The value for `key` interpreted as a list of strings. * * Handles all three array shapes: * - a multiline dash list (`- item`), * - an inline bracket array (`[a, b, c]`), * - a bare comma-separated scalar (`a, b`). * * Returns `undefined` if the key is absent. Quotes are stripped and empty * items are dropped. */ getStringArray(key: string): string[] | undefined; /** * The value for `key` interpreted as a boolean. * * Only the literal string `true` is truthy; anything else (including an * absent key) is `false`. */ getBoolean(key: string): boolean; } /** * Parse the frontmatter block out of a file's already split lines. * * @param lines - File content split on `\n` (as produced by `ContextFile`). * @returns A typed {@link Frontmatter} view; `hasFence` is `false` when no * `---` delimiter is present. */ export declare class FrontmatterParser { static parse(lines: string[]): Frontmatter; } export {}; //# sourceMappingURL=FrontmatterParser.d.ts.map