| 478 | } |
| 479 | |
| 480 | func cleanBundledSkillRelativePath(relativePath string) (string, error) { |
| 481 | cleaned := path.Clean(strings.TrimSpace(strings.ReplaceAll(relativePath, "\\", "/"))) |
| 482 | switch { |
| 483 | case cleaned == ".", cleaned == "": |
| 484 | return "", errors.New("skill file path is required") |
| 485 | case strings.HasPrefix(cleaned, "/"): |
| 486 | return "", errors.New("skill file path must be relative") |
| 487 | case cleaned == "..", strings.HasPrefix(cleaned, "../"): |
| 488 | return "", errors.New("skill file path must stay within the skill directory") |
| 489 | default: |
| 490 | return cleaned, nil |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | func cleanFilesystemSkillRelativePath(relativePath string) (string, error) { |
| 495 | cleaned := filepath.Clean(strings.TrimSpace(relativePath)) |