vtcode_skills/limits.rs
1//! Agent Skills specification limits.
2//!
3//! Two validators enforce the same spec: [`SkillManifest::validate`] fails fast
4//! on the first violation, while [`crate::enhanced_validator::ComprehensiveSkillValidator`]
5//! collects every violation with a remediation hint. They differ in *reporting*
6//! only, so the limits themselves live here once — otherwise changing a number
7//! in one validator would silently desync the other.
8//!
9//! Each constant is a character or entry count from the spec, not a byte size.
10//!
11//! [`SkillManifest::validate`]: crate::types::SkillManifest::validate
12//!
13//! # Examples
14//!
15//! ```
16//! use vtcode_skills::limits::MAX_SKILL_NAME_CHARS;
17//!
18//! assert_eq!(MAX_SKILL_NAME_CHARS, 64);
19//! ```
20
21/// Maximum characters in a skill `name` (lowercase letters, digits, hyphens).
22pub const MAX_SKILL_NAME_CHARS: usize = 64;
23
24/// Maximum characters in a skill `description`.
25pub const MAX_SKILL_DESCRIPTION_CHARS: usize = 1024;
26
27/// Maximum characters in a skill `license` string.
28pub const MAX_LICENSE_CHARS: usize = 512;
29
30/// Maximum characters in a skill `compatibility` string.
31pub const MAX_COMPATIBILITY_CHARS: usize = 500;
32
33/// Maximum number of entries in a skill's `allowed-tools` list.
34pub const MAX_ALLOWED_TOOLS: usize = 16;
35
36/// Count the space-delimited tools in an `allowed-tools` value.
37///
38/// This is how [`MAX_ALLOWED_TOOLS`] is measured, so it lives next to the limit
39/// rather than being re-derived by each validator. Counting the iterator avoids
40/// materializing a `Vec` that would only be read for its length.
41///
42/// # Examples
43///
44/// ```
45/// use vtcode_skills::limits::allowed_tool_count;
46///
47/// assert_eq!(allowed_tool_count("Read Write Bash"), 3);
48/// assert_eq!(allowed_tool_count(" Read Write "), 2);
49/// assert_eq!(allowed_tool_count(""), 0);
50/// ```
51#[must_use]
52pub fn allowed_tool_count(allowed_tools: &str) -> usize {
53 allowed_tools.split_whitespace().count()
54}