mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
b3a7b7ad64
* feat: add agent self-evolution * fix ci * delete unused doc * fix lint * fix evolution review issues
30 lines
704 B
Go
30 lines
704 B
Go
package skills
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/utils"
|
|
)
|
|
|
|
func ValidateSkillName(name string) error {
|
|
trimmed := strings.TrimSpace(name)
|
|
if trimmed == "" {
|
|
return fmt.Errorf("skill name is required")
|
|
}
|
|
if filepath.IsAbs(trimmed) {
|
|
return fmt.Errorf("skill name must not be an absolute path")
|
|
}
|
|
if err := utils.ValidateSkillIdentifier(trimmed); err != nil {
|
|
return fmt.Errorf("skill name is invalid: %w", err)
|
|
}
|
|
if len(trimmed) > MaxNameLength {
|
|
return fmt.Errorf("skill name exceeds %d characters", MaxNameLength)
|
|
}
|
|
if !namePattern.MatchString(trimmed) {
|
|
return fmt.Errorf("skill name must be alphanumeric with hyphens")
|
|
}
|
|
return nil
|
|
}
|