/** * One packaged skill, shaped for the OpenCode v2 `SkillEditor.add` contract. * * Field-for-field the host's own derivation for a `/SKILL.md` file * (`core/src/config/plugin/skill-file.ts:41-57`): `id` is the containing * directory's basename, `name` falls back to `id`, `description` is OMITTED * rather than set to `undefined` when the frontmatter has none, `location` and * `path` are both the absolute path to `SKILL.md`, and `content` is the body * verbatim. * * WHY TWO KEYS FOR ONE VALUE. `@opencode/schema` renamed the file key of * `Skill.Info` from `location` to `path` in OpenCode 2.0.4 (compare * `@opencode/schema@2.0.3` and `@2.0.4` `dist/skill.js`). The host decodes what * `draft.add` receives with that schema, and a missing required key is a * `SchemaError` that DISABLES the whole plugin at startup ("Missing key at * [\"path\"]" on >= 2.0.4; "Missing key at [\"location\"]" on <= 2.0.3), taking * every agent, command, and the `subagent` tool with it. `Schema.Struct` * ignores keys it does not declare, so a record carrying both decodes on every * OpenCode 2 release: <= 2.0.3 keeps `location` and drops `path`, >= 2.0.4 the * reverse. Emitting both is therefore the ONLY shape that needs no host-version * probe (the plugin API exposes none for the schema) and cannot regress either * side. Drop `location` only once <= 2.0.3 is out of support. (Dual-key design: * PR #12 by @clopca / issue #10; the registrar types the record against the * stable 2.0.20 `Skill.Info`, and schema regression coverage rejects the old * location-only shape.) * * `slash` and `autoinvoke` are deliberately absent. The host derives them from a * `slash` key or an `opencode/slash` / `opencode/autoinvoke` metadata entry * (`skill-file.ts:45-46`); no corpus file carries either, so emitting them would * invent policy the corpus never authored. */ export interface SkillRecord { readonly id: string; readonly name: string; readonly description?: string; /** Absolute path to `SKILL.md`; the key OpenCode <= 2.0.3 requires. */ readonly location: string; /** The same absolute path; the key OpenCode >= 2.0.4 requires. */ readonly path: string; readonly content: string; } /** * Load every packaged skill under `skillDir`. * * PURE with respect to the host: it reads the packaged corpus and returns * records. It logs nothing and touches no draft, so `register-skills.ts` can call * it once per `setup()` and hand the result to a transform closure that the host * is free to replay. * * A directory is a skill exactly when it contains `SKILL.md`; anything else under * `skillDir` (a stray file, a directory without the marker) is skipped, which * mirrors the host's own file-driven discovery. Results are sorted by `id` so the * record order does not depend on filesystem enumeration order — registration * order is irrelevant to the host (ids are unique and land in a `Map`), but a * stable order keeps the loader's output reproducible for callers and tests. * * Fail direction: a malformed `SKILL.md` throws and takes the whole load with it, * matching `load-agents.ts:52-54` / `load-commands.ts:53-55`. Under v2 that * aborts `setup()` and `server.ts` unwinds, so the user gets NO corvus rather * than a corpus quietly missing a skill an agent's prompt depends on. Reporting * and skipping is not available to a pure loader, which is the other reason the * direction is fail-closed. * * @throws Error when a `SKILL.md` cannot be read or its frontmatter is malformed. */ export declare function loadSkills(skillDir: string): SkillRecord[]; //# sourceMappingURL=load-skills.d.ts.map