InstallForTool writes the skill content to the appropriate location for a tool.
(tool AgentTool, content []byte)
| 161 | |
| 162 | // InstallForTool writes the skill content to the appropriate location for a tool. |
| 163 | func InstallForTool(tool AgentTool, content []byte) (string, error) { |
| 164 | cwd, err := os.Getwd() |
| 165 | if err != nil { |
| 166 | return "", err |
| 167 | } |
| 168 | |
| 169 | skillDir := filepath.Join(cwd, tool.SkillDir) |
| 170 | if err := os.MkdirAll(skillDir, 0755); err != nil { |
| 171 | return "", fmt.Errorf("create directory %s: %w", skillDir, err) |
| 172 | } |
| 173 | |
| 174 | destPath := filepath.Join(skillDir, tool.SkillFile) |
| 175 | if err := os.WriteFile(destPath, content, 0644); err != nil { |
| 176 | return "", fmt.Errorf("write skill file: %w", err) |
| 177 | } |
| 178 | |
| 179 | return destPath, nil |
| 180 | } |
| 181 | |
| 182 | // StripFrontmatter removes YAML frontmatter (between --- delimiters) from content. |
| 183 | func StripFrontmatter(content []byte) []byte { |
no test coverage detected