Class: Riffer::Skills::Frontmatter
- Inherits:
-
Object
- Object
- Riffer::Skills::Frontmatter
- Defined in:
- lib/riffer/skills/frontmatter.rb
Overview
Immutable value object holding parsed SKILL.md YAML frontmatter. Required fields: name and description; the optional disable-model-invocation flag is recognized, and any other unrecognized top-level keys are merged into metadata.
Constant Summary collapse
- NAME_PATTERN =
: Regexp
/\A[a-z0-9]+(-[a-z0-9]+)*\z/- MAX_NAME_LENGTH =
: Integer
64- MAX_DESCRIPTION_LENGTH =
: Integer
1024
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
The skill description (1-1024 chars).
-
#disable_model_invocation ⇒ Object
readonly
Whether the skill opts out of model-driven activation.
-
#metadata ⇒ Object
readonly
Metadata from the spec’s
metadatafield plus any unrecognized top-level keys. -
#name ⇒ Object
readonly
The skill name (1-64 chars, lowercase alphanumeric and hyphens).
Class Method Summary collapse
-
.parse(raw) ⇒ Object
Parses a raw SKILL.md string into a [Frontmatter, body] pair — public so custom backends needn’t reimplement parsing.
-
.parse_frontmatter(raw) ⇒ Object
Parses only the frontmatter from a raw SKILL.md string, ignoring the body.
Instance Method Summary collapse
-
#initialize(name:, description:, disable_model_invocation: false, metadata: {}) ⇒ Frontmatter
constructor
Raises Riffer::ArgumentError if
nameordescriptionis invalid.
Constructor Details
#initialize(name:, description:, disable_model_invocation: false, metadata: {}) ⇒ Frontmatter
Raises Riffer::ArgumentError if name or description is invalid. disable_model_invocation is treated as set only when literally true. – : (name: String, description: String, ?disable_model_invocation: bool, ?metadata: Hash[Symbol, untyped]) -> void
70 71 72 73 74 75 76 77 |
# File 'lib/riffer/skills/frontmatter.rb', line 70 def initialize(name:, description:, disable_model_invocation: false, metadata: {}) validate_name!(name) validate_description!(description) @name = name.freeze @description = description.freeze @disable_model_invocation = (disable_model_invocation == true) @metadata = .freeze end |
Instance Attribute Details
#description ⇒ Object (readonly)
The skill description (1-1024 chars).
19 20 21 |
# File 'lib/riffer/skills/frontmatter.rb', line 19 def description @description end |
#disable_model_invocation ⇒ Object (readonly)
Whether the skill opts out of model-driven activation. Hidden from the catalog and rejected at model activation; still reachable via programmatic activation.
24 25 26 |
# File 'lib/riffer/skills/frontmatter.rb', line 24 def disable_model_invocation @disable_model_invocation end |
#metadata ⇒ Object (readonly)
Metadata from the spec’s metadata field plus any unrecognized top-level keys.
28 29 30 |
# File 'lib/riffer/skills/frontmatter.rb', line 28 def @metadata end |
#name ⇒ Object (readonly)
The skill name (1-64 chars, lowercase alphanumeric and hyphens).
16 17 18 |
# File 'lib/riffer/skills/frontmatter.rb', line 16 def name @name end |
Class Method Details
.parse(raw) ⇒ Object
Parses a raw SKILL.md string into a [Frontmatter, body] pair — public so custom backends needn’t reimplement parsing. Raises Riffer::ArgumentError if the frontmatter is invalid. – : (String) -> [Riffer::Skills::Frontmatter, String]
35 36 37 38 39 |
# File 'lib/riffer/skills/frontmatter.rb', line 35 def self.parse(raw) yaml, body = split_frontmatter(raw) raise Riffer::ArgumentError, "missing YAML frontmatter (expected --- delimiters)" if yaml.empty? [new(name: yaml.delete(:name), description: yaml.delete(:description), disable_model_invocation: yaml.delete(:"disable-model-invocation"), metadata: yaml), body] end |
.parse_frontmatter(raw) ⇒ Object
Parses only the frontmatter from a raw SKILL.md string, ignoring the body. Raises Riffer::ArgumentError if the frontmatter is invalid. – : (String) -> Riffer::Skills::Frontmatter
45 46 47 48 49 |
# File 'lib/riffer/skills/frontmatter.rb', line 45 def self.parse_frontmatter(raw) yaml, _ = split_frontmatter(raw) raise Riffer::ArgumentError, "missing YAML frontmatter (expected --- delimiters)" if yaml.empty? new(name: yaml.delete(:name), description: yaml.delete(:description), disable_model_invocation: yaml.delete(:"disable-model-invocation"), metadata: yaml) end |