Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

45 lines
1.6 KiB
Go

package runtimeprep
import (
"fmt"
"os"
"path/filepath"
"strings"
)
func prepareClaudePersonalSkillDirectory(runtimeRoot string, personalSkillRoot string) (string, error) {
personalSkillRoot = filepath.Clean(strings.TrimSpace(personalSkillRoot))
if personalSkillRoot == "." {
return "", nil
}
if !filepath.IsAbs(personalSkillRoot) || personalSkillRoot == string(filepath.Separator) {
return "", fmt.Errorf("claude personal skill root must be an absolute non-root path")
}
personalInfo, err := os.Lstat(personalSkillRoot)
if err != nil {
return "", fmt.Errorf("inspect Claude personal skill root: %w", err)
}
if personalInfo.Mode()&os.ModeSymlink != 0 || !personalInfo.IsDir() {
return "", fmt.Errorf("claude personal skill root must be a real directory: %s", personalSkillRoot)
}
additionalDirectory := filepath.Join(runtimeRoot, "claude-personal-skills")
claudeDirectory := filepath.Join(additionalDirectory, ".claude")
if err := os.MkdirAll(claudeDirectory, 0o700); err != nil {
return "", fmt.Errorf("create Claude personal skill projection: %w", err)
}
target := filepath.Join(claudeDirectory, "skills")
if targetInfo, err := os.Stat(target); err == nil {
if os.SameFile(targetInfo, personalInfo) {
return additionalDirectory, nil
}
return "", fmt.Errorf("claude personal skill projection targets a different directory: %s", target)
} else if !os.IsNotExist(err) {
return "", fmt.Errorf("inspect Claude personal skill projection: %w", err)
}
if err := exposeCodexSharedDirectory(personalSkillRoot, target); err != nil {
return "", fmt.Errorf("expose Claude personal skill root: %w", err)
}
return additionalDirectory, nil
}