import type { Paths } from "./paths.js"; import { type LoadedProject } from "./projects.js"; import { type Skill, type SkillLoadResult, type SkillSource } from "./skills.js"; /** A skill or hook that appeared, changed (another file or mtime) or disappeared since the registry last saw it. */ export interface SkillChange { name: string; action: "added" | "changed" | "removed"; source: SkillSource; /** The content hash of the definition as it now is; null when removed or without one. */ definition_sha256: string | null; } export interface RegistryOptions { /** Linked project entries (directories or skillhook.yaml paths), re-read on every lookup so `skillhook link` needs no restart. */ projects?: () => string[]; /** Base for relative project entries (default: the process cwd). */ base?: string; /** Where cloud-managed skills live (`/cloud-skills`, src/managed-state.ts); without it none are served. */ cloudSkillsDir?: string; /** Whether cloud-managed skills are served at all (`cloud.managed_skills`, read at every lookup); default: yes when `cloudSkillsDir` is given. */ managedEnabled?: () => boolean; /** Called for every change noticed after the first `list()`; `onChange()` on the instance adds more listeners. */ onChange?: (change: SkillChange) => void; } export interface RegistryListResult extends SkillLoadResult { projects: LoadedProject[]; } /** The `projects` array of `skillhook.json`, cached until the file's mtime changes; tolerant of a missing or invalid file. */ export declare function configProjects(paths: Paths): () => string[]; /** * Every routable skill: the directories under `/skills` first, then the hooks of each linked project in * config order, then the skills Skillhook Cloud assigned to this machine (`/cloud-skills`, docs/cloud.md). * `get()` re-reads a skill whose SKILL.md changed, a project whose skillhook.yaml (or a referenced SKILL.md) changed and * a cloud skill whose installed definition changed; `list()` rescans everything. Edits apply to the next webhook without * a restart. A name defined twice belongs to the earlier source; the later definition is reported as an error, so a * local file always wins over what the cloud sent. * Changes noticed by either call are reported to `onChange` listeners once a first `list()` has primed the registry * (the server lists at startup), so a listener sees edits, not the initial inventory. Every skill carries its * `definition` (the content hash of its files, src/definitions.ts), recomputed only when those files change. */ export declare class SkillRegistry { readonly skillsDir: string; private readonly options; private cache; private projectCache; private cloudCache; private known; private primed; private watchers; private readonly definitions; private readonly managed?; constructor(skillsDir: string, options?: RegistryOptions); /** Adds a change listener; returns the unsubscribe function. */ onChange(fn: (change: SkillChange) => void): () => void; private notify; /** Attaches the definition summary (cached by the files' stamps) and returns the skill. */ private decorate; private note; private forget; private entries; private project; /** Every linked project, loaded (with errors, if any). */ projects(): LoadedProject[]; /** One cloud-managed skill as its state entry says, from the cache while the installed definition and its file are unchanged. */ private cloudSkill; /** The cloud-managed skills, in name order, with the ones that do not load. */ private cloudSkills; list(): RegistryListResult; /** The skill or hook named `name`, or undefined. Throws `SkillError` when its definition exists but is invalid. */ get(name: string, options?: { reloadProject?: string; }): Skill | undefined; }