mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-30 00:20:49 +00:00
* feat(skills): add bulk management actions * feat(skills): improve operations UX * feat(skills): clarify access modes and repair file paths
43 lines
966 B
Go
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)
|
|
}
|