Remove remaining unused helper wrappers

This commit is contained in:
LPF
2026-03-17 13:55:00 +08:00
parent 0674d85ae1
commit 57bb35e784
4 changed files with 2 additions and 108 deletions

View File

@@ -37,30 +37,6 @@ func onboard() {
fmt.Println(" 1. Chat: clawgo agent -m \"Hello!\"")
}
func ensureConfigOnboard(configPath string, defaults *config.Config) (string, error) {
if defaults == nil {
return "", fmt.Errorf("defaults is nil")
}
if defaults.Gateway.Token == "" {
defaults.Gateway.Token = config.DefaultConfig().Gateway.Token
}
exists := true
if _, err := os.Stat(configPath); os.IsNotExist(err) {
exists = false
} else if err != nil {
return "", err
}
if err := config.SaveConfig(configPath, defaults); err != nil {
return "", err
}
if exists {
return "overwritten", nil
}
return "created", nil
}
func copyEmbeddedToTarget(targetDir string, overwrite func(relPath string) bool) error {
if err := os.MkdirAll(targetDir, 0755); err != nil {
return fmt.Errorf("failed to create target directory: %w", err)

View File

@@ -8,7 +8,6 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
@@ -24,12 +23,6 @@ type AvailableSkill struct {
Tags []string `json:"tags"`
}
type BuiltinSkill struct {
Name string `json:"name"`
Path string `json:"path"`
Enabled bool `json:"enabled"`
}
func NewSkillInstaller(workspace string) *SkillInstaller {
return &SkillInstaller{
workspace: workspace,
@@ -57,7 +50,7 @@ func (si *SkillInstaller) InstallFromGitHub(ctx context.Context, repo string) er
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to fetch skill: HTTP %d", resp.StatusCode)
}
@@ -107,7 +100,7 @@ func (si *SkillInstaller) ListAvailableSkills(ctx context.Context) ([]AvailableS
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to fetch skills list: HTTP %d", resp.StatusCode)
}
@@ -123,49 +116,3 @@ func (si *SkillInstaller) ListAvailableSkills(ctx context.Context) ([]AvailableS
return skills, nil
}
func (si *SkillInstaller) ListBuiltinSkills() []BuiltinSkill {
builtinSkillsDir := filepath.Join(filepath.Dir(si.workspace), "clawgo", "skills")
entries, err := os.ReadDir(builtinSkillsDir)
if err != nil {
return nil
}
var skills []BuiltinSkill
for _, entry := range entries {
if entry.IsDir() {
_ = entry
skillName := entry.Name()
skillFile := filepath.Join(builtinSkillsDir, skillName, "SKILL.md")
data, err := os.ReadFile(skillFile)
description := ""
if err == nil {
content := string(data)
if idx := strings.Index(content, "\n"); idx > 0 {
firstLine := content[:idx]
if strings.Contains(firstLine, "description:") {
descLine := strings.Index(content[idx:], "\n")
if descLine > 0 {
description = strings.TrimSpace(content[idx+descLine : idx+descLine])
}
}
}
}
// skill := BuiltinSkill{
// Name: skillName,
// Path: description,
// Enabled: true,
// }
status := "✓"
fmt.Printf(" %s %s\n", status, entry.Name())
if description != "" {
fmt.Printf(" %s\n", description)
}
}
}
return skills
}

View File

@@ -162,22 +162,6 @@ func (sl *SkillsLoader) LoadSkill(name string) (string, bool) {
return "", false
}
func (sl *SkillsLoader) LoadSkillsForContext(skillNames []string) string {
if len(skillNames) == 0 {
return ""
}
var parts []string
for _, name := range skillNames {
content, ok := sl.LoadSkill(name)
if ok {
parts = append(parts, fmt.Sprintf("### Skill: %s\n\n%s", name, content))
}
}
return strings.Join(parts, "\n\n---\n\n")
}
func (sl *SkillsLoader) BuildSkillsSummary() string {
allSkills := sl.ListSkills()
if len(allSkills) == 0 {

View File

@@ -1223,19 +1223,6 @@ func buildMCPDynamicToolName(serverName, remoteName string) string {
return trimmed + suffix
}
func ParseMCPDynamicToolName(name string) (serverName string, remoteName string, ok bool) {
const prefix = "mcp__"
if !strings.HasPrefix(strings.TrimSpace(name), prefix) {
return "", "", false
}
rest := strings.TrimPrefix(strings.TrimSpace(name), prefix)
parts := strings.SplitN(rest, "__", 2)
if len(parts) != 2 || strings.TrimSpace(parts[0]) == "" || strings.TrimSpace(parts[1]) == "" {
return "", "", false
}
return parts[0], parts[1], true
}
var mcpToolSegmentPattern = regexp.MustCompile(`[^a-zA-Z0-9_]+`)
func sanitizeMCPToolSegment(in string) string {