feat: adapt preloaded skills to smart-reasoning agent
This commit is contained in:
@@ -236,7 +236,7 @@ func (l *Loader) LoadSkillFile(skillName, relativePath string) (*SkillFile, erro
|
||||
|
||||
return &SkillFile{
|
||||
Name: relativePath,
|
||||
Path: fullPath,
|
||||
Path: absFilePath, // Use absolute path for sandbox execution
|
||||
Content: string(content),
|
||||
IsScript: IsScript(relativePath),
|
||||
}, nil
|
||||
@@ -287,7 +287,7 @@ func (l *Loader) GetSkillByName(name string) (*Skill, bool) {
|
||||
return skill, ok
|
||||
}
|
||||
|
||||
// GetSkillBasePath returns the base path for a skill
|
||||
// GetSkillBasePath returns the base path for a skill (always absolute)
|
||||
func (l *Loader) GetSkillBasePath(skillName string) (string, error) {
|
||||
skill, ok := l.discoveredSkills[skillName]
|
||||
if !ok {
|
||||
@@ -297,7 +297,8 @@ func (l *Loader) GetSkillBasePath(skillName string) (string, error) {
|
||||
return "", fmt.Errorf("skill not found: %s", skillName)
|
||||
}
|
||||
}
|
||||
return skill.BasePath, nil
|
||||
// Return absolute path for consistent sandbox execution
|
||||
return filepath.Abs(skill.BasePath)
|
||||
}
|
||||
|
||||
// Reload clears the cache and rediscovers all skills
|
||||
|
||||
@@ -172,7 +172,7 @@ func (m *Manager) ListSkillFiles(ctx context.Context, skillName string) ([]strin
|
||||
}
|
||||
|
||||
// ExecuteScript executes a script from a skill in the sandbox
|
||||
func (m *Manager) ExecuteScript(ctx context.Context, skillName, scriptPath string, args []string) (*sandbox.ExecuteResult, error) {
|
||||
func (m *Manager) ExecuteScript(ctx context.Context, skillName, scriptPath string, args []string, stdin string) (*sandbox.ExecuteResult, error) {
|
||||
if !m.enabled {
|
||||
return nil, fmt.Errorf("skills are not enabled")
|
||||
}
|
||||
@@ -207,6 +207,7 @@ func (m *Manager) ExecuteScript(ctx context.Context, skillName, scriptPath strin
|
||||
Script: file.Path,
|
||||
Args: args,
|
||||
WorkDir: basePath,
|
||||
Stdin: stdin,
|
||||
}
|
||||
|
||||
// Execute in sandbox
|
||||
|
||||
@@ -23,8 +23,8 @@ const (
|
||||
// Reserved words that cannot be used in skill names
|
||||
var reservedWords = []string{"anthropic", "claude"}
|
||||
|
||||
// namePattern validates skill names: lowercase letters, numbers, and hyphens only
|
||||
var namePattern = regexp.MustCompile(`^[a-z0-9-]+$`)
|
||||
// namePattern validates skill names: unicode letters, numbers only
|
||||
var namePattern = regexp.MustCompile(`^[\p{L}\p{N}-]+$`)
|
||||
|
||||
// xmlTagPattern detects XML tags in content
|
||||
var xmlTagPattern = regexp.MustCompile(`<[^>]+>`)
|
||||
|
||||
Reference in New Issue
Block a user