| 444 | } |
| 445 | |
| 446 | func locateExtractedSkillFile(root string) (string, error) { |
| 447 | var matches []string |
| 448 | |
| 449 | err := filepath.WalkDir(root, func(current string, entry fs.DirEntry, walkErr error) error { |
| 450 | if walkErr != nil { |
| 451 | return walkErr |
| 452 | } |
| 453 | if entry.IsDir() { |
| 454 | return nil |
| 455 | } |
| 456 | if entry.Name() != skillMarkdownFileName { |
| 457 | return nil |
| 458 | } |
| 459 | matches = append(matches, current) |
| 460 | if len(matches) > 1 { |
| 461 | return errors.New("multiple SKILL.md files found in archive") |
| 462 | } |
| 463 | return nil |
| 464 | }) |
| 465 | if err != nil { |
| 466 | return "", err |
| 467 | } |
| 468 | if len(matches) == 0 { |
| 469 | return "", errors.New("archive did not contain SKILL.md") |
| 470 | } |
| 471 | return matches[0], nil |
| 472 | } |
| 473 | |
| 474 | func moveInstalledSkillDir(extractedDir string, targetDir string, replaceExisting bool) error { |
| 475 | return registrypkg.MoveInstalledDir(extractedDir, targetDir, replaceExisting) |