Files
skillshare/internal/utils/frontmatter.go
T
Willie Hung fd4387460a feat: Team Edition - tracked repos, nested skills, collision detection
## New Features
- Tracked repositories: `install --track` to clone team skill repos
- Nested skills: organize in folders, auto-flatten on sync (work/api → work__api)
- Name collision detection: warns when multiple skills share same SKILL.md name
- Auto-pruning: orphaned symlinks cleaned on sync
- Custom naming: `--name` flag for tracked repos

## Changes
- Require target path to exist when adding targets
- Add sync reminder after adding target
- Improve pruning messages (broken vs orphan symlinks)
- Add `{team}:{name}` naming convention recommendation

## Files
- New: update.go, gitignore.go, frontmatter.go
- Updated: sync.go, install.go, uninstall.go, validate.go
- Docs: README.md, SKILL.md
2026-01-20 01:56:07 +08:00

50 lines
1000 B
Go

package utils
import (
"bufio"
"os"
"path/filepath"
"strings"
)
// ParseSkillName reads the SKILL.md and extracts the "name" from frontmatter.
func ParseSkillName(skillPath string) (string, error) {
skillFile := filepath.Join(skillPath, "SKILL.md")
file, err := os.Open(skillFile)
if err != nil {
return "", err
}
defer file.Close()
scanner := bufio.NewScanner(file)
inFrontmatter := false
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
// Detect frontmatter delimiters
if line == "---" {
if inFrontmatter {
break // End of frontmatter
}
inFrontmatter = true
continue
}
if inFrontmatter {
if strings.HasPrefix(line, "name:") {
// Extract value: "name: my-skill" -> "my-skill"
parts := strings.SplitN(line, ":", 2)
if len(parts) == 2 {
name := strings.TrimSpace(parts[1])
// Remove quotes if present
name = strings.Trim(name, `"'`)
return name, nil
}
}
}
}
return "", nil // Name not found
}