|
| 1 | +# SPDX-FileCopyrightText: Sudo Apt Holdings LLC |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | +defmodule Trinity.Skills do |
| 4 | + @moduledoc """ |
| 5 | + Procedural memory (slice 040, ADR-0006): skills are directories with a `SKILL.md` in the |
| 6 | + agentskills.io format, found under three roots in precedence order (a project's |
| 7 | + `.trinity/skills`, the data directory's `skills`, the bundled `priv/skills`), parsed into |
| 8 | + `Trinity.Skills.Skill`, indexed in the `skills` table and held by `Trinity.Skills.Registry`, |
| 9 | + and shown to the model by progressive disclosure: the index in the prompt, the body on |
| 10 | + `skill_view`, a reference file on `skill_file`. The filesystem is canonical; the table is |
| 11 | + an index a reindex rebuilds. Nothing here writes a skill: that is slice 041's. |
| 12 | +
|
| 13 | + Depends on Tools because conditional activation asks the registry which tools and |
| 14 | + toolsets exist, and because the three skill tools implement `Trinity.Tools.Tool`; Tools |
| 15 | + never depends on Skills. |
| 16 | + """ |
| 17 | + use Boundary, |
| 18 | + deps: [Trinity, Trinity.Tools, Trinity.Memory], |
| 19 | + exports: [Skill, Parser, Sources, Registry, Row, Index, Tools.List, Tools.View, Tools.File] |
| 20 | + |
| 21 | + alias Trinity.Skills.Registry |
| 22 | + |
| 23 | + @doc "The effective skills (one per name, by precedence); `project_root:` adds a project's." |
| 24 | + @spec list(keyword()) :: [Trinity.Skills.Skill.t()] |
| 25 | + defdelegate list(opts \\ []), to: Registry |
| 26 | + |
| 27 | + @doc "The skills the model may see now: active, and their requirements met." |
| 28 | + @spec active(keyword()) :: [Trinity.Skills.Skill.t()] |
| 29 | + defdelegate active(opts \\ []), to: Registry |
| 30 | + |
| 31 | + @doc "A skill by name, among the effective ones." |
| 32 | + @spec get(String.t(), keyword()) :: Trinity.Skills.Skill.t() | nil |
| 33 | + defdelegate get(name, opts \\ []), to: Registry |
| 34 | + |
| 35 | + @doc "Rescans every root and rewrites the index." |
| 36 | + @spec rescan() :: :ok |
| 37 | + defdelegate rescan(), to: Registry |
| 38 | + |
| 39 | + @doc "Enables or disables a skill by name and source; persisted in the index." |
| 40 | + @spec set_status(String.t(), String.t(), String.t()) :: :ok | {:error, term()} |
| 41 | + defdelegate set_status(name, source, status), to: Registry |
| 42 | +end |
0 commit comments