/** * Skill Loader — extracted from agent-loop.ts (STORY-009) * * Handles skill discovery, catalog building, and content loading * for the MAMA OS system prompt injection pipeline. * * STORY-010: Semantic section-based truncation — skills over token budget * are split at section boundaries and lowest-priority sections omitted. */ import type { AgentContext } from './types.js'; /** * Result of loading a skill's content. */ export interface SkillLoadResult { content: string; truncated: boolean; omittedSections: string[]; originalChars: number; } /** * Parsed YAML frontmatter from a skill .md file. */ export interface SkillFrontmatter { name: string; description: string; keywords: string[]; } /** A parsed section of a skill markdown file. */ export interface SkillSection { name: string; content: string; tokens: number; priority: number; } /** * Parse skill markdown into semantic sections. * Splits on `## ` headings and `---` dividers. * Frontmatter (---...---) is always priority 1. */ export declare function parseSkillSections(content: string): SkillSection[]; /** * Truncate skill content by omitting lowest-priority sections first. * Never cuts mid-section. Appends [Omitted: ...] marker. * * @param content - Raw skill markdown content * @param maxTokens - Token budget (default: skill_max_tokens config) * @returns SkillLoadResult with truncation metadata */ export declare function truncateSkillBySections(content: string, maxTokens?: number): SkillLoadResult; /** * Parse YAML frontmatter from skill .md file content. */ export declare function parseSkillFrontmatter(content: string): SkillFrontmatter; /** * Find the main .md file for a directory skill (for frontmatter parsing). */ export declare function findMainSkillFile(skillDir: string, skillName: string): string | null; /** * Recursively collect all .md files from a directory (sync). * Filters out non-essential files (LICENSE, CONNECTORS, etc.) * Uses semantic section-based truncation for files exceeding token limit. */ export declare function collectMarkdownFiles(dir: string, prefix?: string): Array<{ path: string; content: string; truncated: boolean; omittedSections: string[]; }>; /** * Build skill catalog (one line per enabled skill) for system prompt. * Format: "- [source/skillId] keywords: kw1, kw2 | description" */ export declare function buildSkillCatalog(verbose?: boolean): string[]; /** * Load full skill content on-demand for per-message injection. * * @param skillId - Skill identifier like "mama/playground" * @returns SkillLoadResult with content and truncation metadata, or null if not found */ export declare function loadSkillContent(skillId: string): SkillLoadResult | null; /** * Load installed & enabled skills from ~/.mama/skills/ * Returns skill catalog lines for system prompt injection (on-demand mode). */ export declare function loadInstalledSkills(verbose?: boolean, _options?: { onlyCommands?: boolean; }): string[]; export declare function filterSkillCatalogForContext(catalog: string[], context?: AgentContext | null): string[]; //# sourceMappingURL=skill-loader.d.ts.map