ReadReference returns the bytes of / and the cleaned path.
(name, relpath string)
| 182 | |
| 183 | // ReadReference returns the bytes of <name>/<relpath> and the cleaned path. |
| 184 | func (r *Reader) ReadReference(name, relpath string) ([]byte, string, error) { |
| 185 | if err := r.ensureSkill(name); err != nil { |
| 186 | return nil, "", err |
| 187 | } |
| 188 | cleaned, err := cleanSubPath(relpath) |
| 189 | if err != nil { |
| 190 | return nil, "", err |
| 191 | } |
| 192 | full := name + "/" + cleaned |
| 193 | info, err := fs.Stat(r.fsys, full) |
| 194 | if err != nil { |
| 195 | return nil, "", errs.NewValidationError(errs.SubtypeInvalidArgument, |
| 196 | "reference %q not found in skill %q", relpath, name). |
| 197 | WithHint("run 'lark-cli skills list " + name + "' to see files in this skill") |
| 198 | } |
| 199 | if info.IsDir() { |
| 200 | return nil, "", errs.NewValidationError(errs.SubtypeInvalidArgument, |
| 201 | "reference %q is a directory, not a file", relpath) |
| 202 | } |
| 203 | data, err := fs.ReadFile(r.fsys, full) |
| 204 | if err != nil { |
| 205 | return nil, "", errs.NewInternalError(errs.SubtypeFileIO, |
| 206 | "failed to read embedded skill content: %v", err) |
| 207 | } |
| 208 | return data, cleaned, nil |
| 209 | } |