package adapter import ( "fmt" "os" "path/filepath" "skillmgr/internal/types" ) // ClaudeAdapter Claude Code 平台适配器 type ClaudeAdapter struct{} // GetSkillInstallPath 获取 skill 安装路径 func (a *ClaudeAdapter) GetSkillInstallPath(scope types.Scope, skillName string) (string, error) { base, err := getBasePath(scope) if err != nil { return "", err } return filepath.Join(base, ".claude", "skills", skillName), nil } // GetCommandInstallPath 获取 command 安装路径 func (a *ClaudeAdapter) GetCommandInstallPath(scope types.Scope, commandGroup string) (string, error) { base, err := getBasePath(scope) if err != nil { return "", err } return filepath.Join(base, ".claude", "commands", commandGroup), nil } // AdaptSkill 适配 skill(遍历源目录,生成文件映射) func (a *ClaudeAdapter) AdaptSkill(sourcePath, destBasePath string) (map[string]string, error) { mapping := make(map[string]string) err := filepath.Walk(sourcePath, func(path string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(sourcePath, path) if err != nil { return fmt.Errorf("计算相对路径失败: %w", err) } destPath := filepath.Join(destBasePath, relPath) if !info.IsDir() { mapping[path] = destPath } return nil }) return mapping, err } // AdaptCommand 适配 command(保持目录结构) func (a *ClaudeAdapter) AdaptCommand(sourcePath, destBasePath, commandGroup string) (map[string]string, error) { mapping := make(map[string]string) files, err := filepath.Glob(filepath.Join(sourcePath, "*.md")) if err != nil { return nil, err } for _, file := range files { fileName := filepath.Base(file) destPath := filepath.Join(destBasePath, fileName) mapping[file] = destPath } return mapping, nil }