# `A2UIAgent.SkillGenerator`
[🔗](https://github.com/a2ui-elixir/a2ui/blob/v0.1.1/umbrella/apps/a2ui_agent/lib/a2ui_agent/skill_generator.ex#L1)

Packages an inference format's prompt as skills
(`A2UIAgent.Skill`).

    {:ok, format} = A2UIAgent.Express.new([catalog])

    {:ok, skill} = A2UIAgent.SkillGenerator.skill(format, name: "a2ui")
    {:ok, skills} = A2UIAgent.SkillGenerator.skill_set(format)
    Enum.map(skills, & &1.filename)
    #=> ["a2ui-core/SKILL.md", "a2ui-basic/SKILL.md"]

A monolithic skill (`skill/2`) holds the whole prompt: the format's
rules, each catalog's instructions and the examples. A skill set
(`skill_set/2`) splits it into a core skill with the rules
(`core_skill/2`) and one skill per catalog (`catalog_skill/3`), named
after the catalog: `a2ui-<name>`, where the name is the last part of
the catalog id that is not a file or a version.

The format must implement the optional `A2UIAgent.Format` callbacks
that give its prompt's pieces, as `A2UIAgent.Express` does.

# `catalog_skill`
*since 0.1.0* 

```elixir
@spec catalog_skill(struct(), A2UICore.Catalog.t() | nil, keyword()) ::
  {:ok, A2UIAgent.Skill.t()} | {:error, A2UICore.Error.t()}
```

The skill of one catalog (default: the format's first): its
instructions and, unless `include_examples: false`, the examples.
Options: `:name` (default `"a2ui-<name>"`), `:description` and
`:include_examples`.

# `clean_name`
*since 0.1.0* 

```elixir
@spec clean_name(String.t() | nil) :: String.t()
```

The name a catalog's skill takes after: the last part of its id that
is not a file name or a version, in lower case.

    iex> A2UIAgent.SkillGenerator.clean_name("https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json")
    "basic"
    iex> A2UIAgent.SkillGenerator.clean_name("acme/widgets/v2")
    "widgets"

# `core_skill`
*since 0.1.0* 

```elixir
@spec core_skill(struct(), keyword()) :: A2UIAgent.Skill.t()
```

The skill with the format's rules. Options: `:name` (default
`"a2ui-core"`) and `:description`.

# `skill`
*since 0.1.0* 

```elixir
@spec skill(struct(), keyword()) ::
  {:ok, A2UIAgent.Skill.t()} | {:error, A2UICore.Error.t()}
```

One skill with the whole prompt. Options: `:name` (default `"a2ui"`),
`:description` and `:catalogs` (default: the format's).

# `skill_set`
*since 0.1.0* 

```elixir
@spec skill_set(struct(), keyword()) ::
  {:ok, [A2UIAgent.Skill.t()]} | {:error, A2UICore.Error.t()}
```

The core skill and one skill per catalog (default: the format's
catalogs). Examples a format gives every catalog go only into the
first catalog's skill. Options: `:catalogs` and `:core_name`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
