pub struct SkillDraft { /* private fields */ }Expand description
A skill to be written to disk.
name and description are required by the specification; everything else is optional and is
omitted from the generated file when unset.
§Example
use adk_skill::SkillDraft;
let draft = SkillDraft::new("disk-triage", "Diagnose low disk space. Use when a disk alert fires.")
.with_body("1. Check the largest directories.\n2. Report growth rate.")
.with_tags(["ops"])
.with_allowed_tools(["read_file"]);
assert_eq!(draft.name(), "disk-triage");Implementations§
Source§impl SkillDraft
impl SkillDraft
Sourcepub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, description: impl Into<String>) -> Self
Creates a draft with the two required fields.
Sourcepub fn with_version(self, version: impl Into<String>) -> Self
pub fn with_version(self, version: impl Into<String>) -> Self
Sets the version identifier.
Sourcepub fn with_license(self, license: impl Into<String>) -> Self
pub fn with_license(self, license: impl Into<String>) -> Self
Sets the license identifier.
Sourcepub fn with_compatibility(self, compatibility: impl Into<String>) -> Self
pub fn with_compatibility(self, compatibility: impl Into<String>) -> Self
Sets the environment requirements.
Sets the discovery tags.
Sourcepub fn with_allowed_tools<I, S>(self, tools: I) -> Self
pub fn with_allowed_tools<I, S>(self, tools: I) -> Self
Sets the pre-approved tool names.
Sourcepub fn with_references<I, S>(self, references: I) -> Self
pub fn with_references<I, S>(self, references: I) -> Self
Sets the supporting resource paths.
Sourcepub fn with_trigger(self, trigger: bool) -> Self
pub fn with_trigger(self, trigger: bool) -> Self
Requires explicit invocation by name rather than automatic selection.
Sourcepub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, Value>) -> Self
Sets the extension metadata.
Useful for recording provenance — which incident a learned skill came from, when it was promoted, and what evidence supported it.
Sourcepub fn with_metadata_entry(self, key: impl Into<String>, value: Value) -> Self
pub fn with_metadata_entry(self, key: impl Into<String>, value: Value) -> Self
Adds one extension metadata entry.
Sourcepub fn with_triggers<I, S>(self, triggers: I) -> Self
pub fn with_triggers<I, S>(self, triggers: I) -> Self
Sets the file glob patterns that activate this skill.
Sourcepub fn validate(&self) -> SkillResult<()>
pub fn validate(&self) -> SkillResult<()>
Checks the draft against the specification.
§Errors
Returns SkillError::Validation when the name is invalid or the description is empty.
Sourcepub fn to_markdown(&self) -> SkillResult<String>
pub fn to_markdown(&self) -> SkillResult<String>
Renders the draft as skill Markdown: YAML frontmatter, then the body.
The output is what parse_skill_markdown accepts, so a
draft written and reparsed yields equivalent content.
§Errors
Returns an error if the draft fails validate or the frontmatter cannot
be serialized.