small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
albedo robot-docs skills.md
5.9 kB · 115 lines
Markdown
at main

Skills extension #

The skills extension discovers instruction files and exposes a session snapshot as context, commands, and Python routes. It requires the commands extension. See skills extension.

The skills catalog is part of the SDK. It is the type behind the per-session skills configuration, which the daemon handles beside instructions and mcp. The modules under sdk/skills own the catalog, frontmatter policy, prompt mentions, and the native scanner. The extension owns session preparation, load records, the loads service, and Python bindings. Core code must not import the extension's modules. The skill command argument list is command.skill_arguments in command.gleam, shared by the extension and the daemon's input catalog.

Discovery #

catalog.scan_at scans workspace, user, and built-in sources. It reads the workspace's project skills from the directory its readable argument answers. The extension passes its preparation's project_files, which the host answers with core's project_files.readable: a remote workspace's mirror. If that mirror is unavailable, it skips project skills and records a diagnostic. Session preparation filters discovered skills through the preparation's capability preferences, read only when it discovered a skill, and keeps a snapshot for that session. The snapshot supplies <available_skills> metadata and commands. See extension.gleam.

The native scanner checks immediate child directories under these roots in order:

  1. <workspace>/.albedo/skills
  2. <workspace>/.agents/skills
  3. $HOME/.albedo/skills
  4. $HOME/.agents/skills
  5. The installation's apps/albedo/priv/skills

Each candidate needs a regular SKILL.md. Its declared name must match the installed directory name. Earlier valid candidates take precedence over later duplicates. Symlinks resolve before the file is read. Root order, filesystem discovery, and selection identity belong to skills/files.

frontmatter owns frontmatter extraction and metadata validation for both discovery and selected-skill revalidation. The closing delimiter must fit within 65,536 bytes, including the delimiter lines and their counted newlines. CRLF delimiters are accepted. The shared albedo_file.read_prefix reads at most 65,537 bytes and closes its descriptor on success or failure. It decodes YAML with yamerl's failsafe schema while retaining duplicate keys, and adapts yamerl's terms in its yaml_node function. Keep metadata policy out of that adapter.

A name uses 1 to 64 lowercase ASCII letters, digits, and single separating hyphens. For compatibility, a single trailing LF is also accepted in a name. An omitted name falls back to the installed directory name, which must pass the same validation. A description is trimmed and must contain 1 to 1,024 Unicode scalars. Duplicate name or description fields are rejected. Other well-formed metadata fields are ignored.

Activation and Python API #

await skills.resources(name) lists resource names. await skills.read(name, resource="SKILL.md", offset=0, limit=16384) reads a bounded page with content, next_offset, and truncated. Failures raise SkillsError. See skills.py and catalog.gleam.

The resource reader accepts at most 65,536 bytes per page and rejects resources larger than 16 MiB. After the existing selected-skill identity, path resolution, and regular-file checks, it uses albedo_file.read_range for bounded byte I/O. The shared helper does not replace those checks. A read error returns a resource error, and EOF returns empty bytes. The response includes its encoding and total size. See read_resource in files.gleam.

Each cataloged skill has a slash command. A reserved command name uses /skill:<name>. A user invocation submits an activation as a turn. The ACP adapter advertises these commands to editors, refreshes them on session catalog invalidation, and accepts skill mentions in prompt text. A model command invocation returns activation data. See command_name in catalog.gleam and skill_command in extension.gleam.

Trust and execution #

The built-in image generation skill describes the imagegen binding and links its prompting guidance, source attribution, and license. Discovering or reading it does not enable a driver or establish that an account is signed in.

Reading or activating a skill does not run its scripts, import modules, fetch links, or grant tools. allowed-tools metadata is descriptive. Resolve relative paths from the installed skill directory. The extension attempts to record loads, but a recording failure does not prevent a load. See instructions, record, and skill_command in extension.gleam and the activation preamble in catalog.gleam.