8679052334
- parse_skill_frontmatter() now returns std::expected<SkillMetadata, std::string> - scan_skills() now returns std::expected<std::vector<SkillMetadata>, std::string> - All throw statements replaced with return std::unexpected() - Filesystem scan errors are now fatal instead of warnings - Updated main.cpp to handle the new return types
33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <optional>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <expected>
|
|
#include "tool.hpp"
|
|
|
|
// Represents parsed YAML frontmatter metadata from a SKILL.md file
|
|
struct SkillMetadata {
|
|
std::string name;
|
|
std::optional<std::string> description;
|
|
std::string raw_content; // Markdown content after YAML frontmatter
|
|
std::vector<std::string> files; // Absolute paths to other files in the skill directory
|
|
std::string directory; // Path to the skill directory
|
|
};
|
|
|
|
// Parse YAML frontmatter from a file and extract content.
|
|
// Returns std::unexpected with error message if the file is malformed or name is missing.
|
|
std::expected<SkillMetadata, std::string> parse_skill_frontmatter(const std::string& filepath);
|
|
|
|
// Scans global and local skill directories and returns parsed SkillMetadata for each discovered skill.
|
|
// Returns std::unexpected with error message if any skill file is malformed or cannot be accessed.
|
|
std::expected<std::vector<SkillMetadata>, std::string> scan_skills();
|
|
|
|
// Prints discovered paths to stdout
|
|
void print_discovered_paths(const std::vector<std::string>& paths);
|
|
|
|
// Prints skill names and descriptions to stdout
|
|
void print_skills(const std::vector<SkillMetadata>& skills);
|
|
|
|
Tool make_skill_tool(const std::vector<SkillMetadata>& enabled_skills);
|