Files
Duy /zuey/andGitHub 81d96ae014 feat(skills): clarify access modes and repair file paths (#31)
* feat(skills): add bulk management actions

* feat(skills): improve operations UX

* feat(skills): clarify access modes and repair file paths
2026-05-21 16:37:50 +07:00

43 lines
966 B
Go

package store
import (
"path/filepath"
"strings"
)
const SkillMarkdownFilename = "SKILL.md"
// SkillBaseDir normalizes a persisted skill file_path into the skill directory.
// Older import paths may point directly to SKILL.md; managed uploads usually
// point to the version directory.
func SkillBaseDir(filePath string) string {
if filePath == "" {
return ""
}
cleaned := filepath.Clean(filePath)
if cleaned == "." {
return ""
}
if strings.EqualFold(filepath.Base(cleaned), SkillMarkdownFilename) {
return filepath.Dir(cleaned)
}
return cleaned
}
func SkillMarkdownPath(filePath string) string {
baseDir := SkillBaseDir(filePath)
if baseDir == "" {
return ""
}
return filepath.Join(baseDir, SkillMarkdownFilename)
}
// SkillSlugDir returns the directory that contains version subdirectories.
func SkillSlugDir(filePath string) string {
baseDir := SkillBaseDir(filePath)
if baseDir == "" {
return ""
}
return filepath.Dir(baseDir)
}