/** * Frontmatter + body validator for skill documents. * * Operates on the output of `parseSkillDocument()` plus the skill's * directory name (used as the default `name`) and source. Returns a typed * `SkillFrontmatter` plus a list of warnings/errors so the manager can * emit `sdk.skill.error` events with the appropriate severity. * * Rules enforced here (everything else is the manager's job — shadowing, * versioning, FQN construction): * * - `name` regex + reserved-word ban + length cap. * - `description` length cap (1024 chars). * - `when_to_use` length cap (1024 chars). * - `allowed-tools` normalization (string-or-array → `AllowedToolEntry[]` * with `Tool(args)` parsed). * - `arguments` normalization (string-or-object form → `SkillArgument[]`). * - `paths` shape (array of strings). * - Booleans for `disable-model-invocation`, `user-invocable`. * - `version` semver shape; defaults to `0.0.0` if absent. * - `min_sdk_version` semver shape. * - `requires` shape (array of strings). * - `effort`, `context`, `shell` enum membership. * - Body size — 50 KB hard error, 500-line warning. * * Unknown frontmatter fields are NOT rejected; they're preserved on * `frontmatter.unknown_fields` for forward compatibility and emitted as * `sdk.skill.unknown_field` debug events. */ import type { JsonValue } from '../qar/json.js'; import type { SkillEventSeverity, SkillFrontmatter } from './types.js'; /** * One validation diagnostic emitted by `validateFrontmatter` / * `validateBody`. The manager translates these into `sdk.skill.error` * events with the skill's path attached. */ export interface ValidationIssue { readonly severity: SkillEventSeverity; readonly message: string; /** When emitted from `validateFrontmatter`, the offending field. */ readonly field?: string; } export interface ValidatedFrontmatter { readonly frontmatter: SkillFrontmatter; readonly issues: readonly ValidationIssue[]; /** Unknown fields preserved verbatim; emit `sdk.skill.unknown_field` per entry. */ readonly unknownFields: readonly string[]; } export interface ValidatedBody { readonly issues: readonly ValidationIssue[]; } /** * Validate parsed frontmatter against the skill contract. Returns a typed * `SkillFrontmatter` (always present — even on failure, the validator * preserves whatever it could parse) plus a list of issues. Fatal issues * carry `severity: 'error'`; the manager treats those as catalog * exclusions. */ export declare function validateFrontmatter(raw: Readonly>, defaultName: string): ValidatedFrontmatter; /** * Validate the body — 50 KB hard cap (error, exclude skill), 500-line soft * cap (warning, include anyway). */ export declare function validateBody(body: string): ValidatedBody; /** * Result of {@link extractBodyReferences} — one entry per `[label](path)` * markdown link OR `get_skill_file(path)` reference observed in the body. * * Only relative paths land in the result; absolute URLs (`https://...`, * `mailto:`, anchors `#section`) are filtered out — they don't reference * supporting files. */ export interface BodyReference { /** The link target — normalized to POSIX separators, stripped of `./`. */ readonly path: string; /** Path-segment depth (number of `/` separators + 1). */ readonly depth: number; } /** * Extract supporting-file references from a SKILL.md body. Two forms are * recognized per `skills-progressive-disclosure.md`: * * - Markdown links: `[label](path/to/file.ext)`. * - Explicit tool calls: `get_skill_file("path/to/file")` (string arg). * * Both must be relative; external URLs and anchors are skipped. */ export declare function extractBodyReferences(body: string): readonly BodyReference[]; /** Compare two semver strings (`a < b`). Both must match `SEMVER_RE`. */ export declare function semverLessThan(a: string, b: string): boolean; /** Return `true` iff the version strings refer to the same version. */ export declare function semverEqual(a: string, b: string): boolean; /** Test helper exposed for the validator's own unit suite. */ export declare function isValidSemver(s: string): boolean; //# sourceMappingURL=validator.d.ts.map