MCPcopy Index your code
hub / github.com/larksuite/cli / ReadReference

Method ReadReference

internal/skillcontent/reader.go:184–209  ·  view source on GitHub ↗

ReadReference returns the bytes of / and the cleaned path.

(name, relpath string)

Source from the content-addressed store, hash-verified

182
183// ReadReference returns the bytes of <name>/<relpath> and the cleaned path.
184func (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}

Callers 2

TestReadReferenceFunction · 0.80
newReadCmdFunction · 0.80

Calls 8

ensureSkillMethod · 0.95
NewValidationErrorFunction · 0.92
NewInternalErrorFunction · 0.92
cleanSubPathFunction · 0.85
StatMethod · 0.65
IsDirMethod · 0.65
ReadFileMethod · 0.65
WithHintMethod · 0.45

Tested by 1

TestReadReferenceFunction · 0.64