MCPcopy Create free account
hub / github.com/53AI/53AIHub / appendSkillFile

Function appendSkillFile

api/service/tools/executor.go:526–545  ·  view source on GitHub ↗
(ctx context.Context, files map[string]string, root string, absPath string, info os.FileInfo)

Source from the content-addressed store, hash-verified

524}
525
526func appendSkillFile(ctx context.Context, files map[string]string, root string, absPath string, info os.FileInfo) error {
527 if info.Size() > 10*1024*1024 {
528 logger.Warnf(ctx, "Skipping large file %s (%d bytes)", absPath, info.Size())
529 return nil
530 }
531 relPath, err := filepath.Rel(root, absPath)
532 if err != nil {
533 return err
534 }
535 relPath = filepath.Clean(relPath)
536 if strings.HasPrefix(relPath, "..") || filepath.IsAbs(relPath) {
537 return fmt.Errorf("path traversal detected: %s", relPath)
538 }
539 content, err := os.ReadFile(absPath)
540 if err != nil {
541 return err
542 }
543 files[filepath.ToSlash(relPath)] = string(content)
544 return nil
545}
546
547func ensureSkillResourcesSeeded(ctx context.Context, sessionID string, cwd string) error {
548 if strings.TrimSpace(sessionID) == "" {

Callers 1

loadSkillFilesForSandboxFunction · 0.85

Calls 3

WarnfMethod · 0.80
ErrorfMethod · 0.80
ReadFileMethod · 0.65

Tested by

no test coverage detected