/** * Skill Content Parser — Markdown AST-based section chunking * * Breaks skill bodies into structured sections so agents load only the parts * they need instead of dumping the entire SKILL.md into context. * * Uses lightweight heading-based parsing (no external Markdown AST library * needed) to produce a tree of sections with token-count estimates. */ /** * A single section of a skill body, parsed from Markdown headings. */ export interface SkillSection { /** Heading text (e.g., "Error Handling") */ heading: string; /** Heading level (1-6) */ level: number; /** Raw Markdown content under this heading (excluding sub-headings) */ content: string; /** Approximate token count (words ÷ 0.75 — conservative estimate) */ tokenEstimate: number; /** Nested sub-sections */ children: SkillSection[]; /** Dot-path for addressing (e.g., "Error Handling.Rate Limits") */ path: string; } /** * Result of parsing a skill body into sections. */ export interface ParsedSkillContent { /** Top-level intro content before any heading */ preamble: string; /** Token estimate for preamble */ preambleTokens: number; /** All top-level sections (with nested children) */ sections: SkillSection[]; /** Total token estimate for the entire body */ totalTokens: number; /** Flat index: heading path → section reference (for fast lookup) */ index: Map; } /** * Options for retrieving skill content with selective loading. */ export interface SkillContentOptions { /** Only return sections matching these heading paths (case-insensitive partial match) */ sections?: string[]; /** Maximum total tokens to return (truncates from the end) */ maxTokens?: number; /** Include the preamble (default: true) */ includePreamble?: boolean; /** Depth limit for section inclusion (1 = top-level only, 2 = include children, etc.) */ maxDepth?: number; } /** * Parse a Markdown skill body into a tree of sections. * * This is a lightweight parser that splits on ATX headings (lines starting * with #). It does NOT handle: * - Setext headings (underline style) * - Headings inside code blocks (these are treated as content) * * For SKILL.md files (which follow a consistent format), this is sufficient. */ export declare function parseSkillSections(body: string): ParsedSkillContent; /** * Selectively extract content from a parsed skill body. * * This is the key function for context management — instead of dumping the * entire SKILL.md into the LLM's context window, agents call this to get * only the sections they need. * * @example * // Get only the error handling section * extractSkillContent(parsed, { sections: ['Error Handling'] }) * * @example * // Get top-level overview only (no sub-sections), max 500 tokens * extractSkillContent(parsed, { maxDepth: 1, maxTokens: 500 }) */ export declare function extractSkillContent(parsed: ParsedSkillContent, options?: SkillContentOptions): string; /** * Get a flat list of all section headings with their token costs. * Useful for agents to decide which sections to load. */ export declare function listSkillSections(parsed: ParsedSkillContent): Array<{ path: string; level: number; tokenEstimate: number; }>; //# sourceMappingURL=skill-content-parser.d.ts.map