Skip to main content

a2a_protocol_server/skills/
spec.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Tom F. <[email protected]> (https://github.com/tomtom215)
3
4//! The Agent Skills specification, as this module read it.
5//!
6//! There are no versioned releases of the specification (ADR 0035), so every
7//! number here is pinned to a date: [`SPEC_SNAPSHOT`]. The text was
8//! `https://agentskills.io/specification` and
9//! `https://agentskills.io/client-implementation/adding-skills-support`; the
10//! reference validator's behaviour (`skills-ref`, as summarised on that date)
11//! is where the Unicode-letter and unknown-field rules come from.
12
13/// The date the specification text this module follows was read, as
14/// `YYYY-MM-DD`. Named in the diagnostics about fields this module does not
15/// understand, because the specification may have changed since.
16pub const SPEC_SNAPSHOT: &str = "2026-11-07";
17
18/// The most characters a `name` may have under the specification.
19pub(super) const MAX_NAME_CHARS: usize = 64;
20
21/// The most characters a `name` may have for this module to use it at all.
22/// The specification's limit is 64; a longer name is reported and used, up
23/// to this bound, so a skill written for a client that does not check is not
24/// lost. Past it the name would only cost prompt tokens.
25pub(super) const MAX_NAME_CHARS_USABLE: usize = 256;
26
27/// The most characters a `description` may have under the specification.
28pub(super) const MAX_DESCRIPTION_CHARS: usize = 1024;
29
30/// The most characters `compatibility` may have under the specification.
31pub(super) const MAX_COMPATIBILITY_CHARS: usize = 500;
32
33/// How many lines the specification recommends a `SKILL.md` stay under.
34pub(super) const RECOMMENDED_BODY_LINES: usize = 500;
35
36/// The frontmatter fields the specification defines, on the date above.
37pub(super) const KNOWN_FIELDS: [&str; 6] = [
38    "name",
39    "description",
40    "license",
41    "compatibility",
42    "metadata",
43    "allowed-tools",
44];
45
46/// The largest frontmatter block this module parses, in bytes. A block over
47/// it is refused before any of it is read as YAML. The specification's own
48/// limits (1024 characters of description, 500 of compatibility, a name of
49/// 64) fit in a few kilobytes even in four-byte characters; 8 KiB leaves room
50/// for `metadata` and comments.
51pub(super) const MAX_FRONTMATTER_BYTES: usize = 8 * 1024;
52
53/// Whether `c` may appear in a skill name this module will use: a Unicode
54/// letter or digit, a hyphen, an underscore or a dot. The specification
55/// allows letters, digits and hyphens; the other two are common in skills
56/// written for clients that do not check, are reported, and cannot do
57/// harm in a prompt. Anything else (a space, a quote, markup, a control
58/// character, a path separator) can, and the skill is skipped.
59pub(super) fn is_usable_name_char(c: char) -> bool {
60    c.is_alphanumeric() || matches!(c, '-' | '_' | '.')
61}
62
63/// Whether `c` is a character the specification allows in a name, case aside:
64/// a Unicode letter or digit, or a hyphen.
65pub(super) fn is_spec_name_char(c: char) -> bool {
66    c == '-' || c.is_alphanumeric()
67}
68
69/// Whether `c` is unchanged by lowercasing, which is what "lowercase" means
70/// for a character with no case (a digit, a hyphen, a CJK ideograph).
71pub(super) fn is_lowercase_invariant(c: char) -> bool {
72    let mut lower = c.to_lowercase();
73    lower.next() == Some(c) && lower.next().is_none()
74}