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
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package runtimeprep
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
func resolveCLICommand(stateDir string) string {
|
|
stateDir = strings.TrimSpace(stateDir)
|
|
if stateDir == "" {
|
|
return "tutti"
|
|
}
|
|
entries, err := os.ReadDir(filepath.Join(stateDir, "bin"))
|
|
if err != nil {
|
|
return "tutti"
|
|
}
|
|
|
|
candidates := make([]string, 0)
|
|
for _, entry := range entries {
|
|
if entry.IsDir() {
|
|
continue
|
|
}
|
|
name := entry.Name()
|
|
base := strings.TrimSuffix(name, ".cmd")
|
|
// Connector-native CLI shims share the state bin directory, but they
|
|
// are not aliases for the Tutti daemon CLI used in generated policy.
|
|
if (base == "tutti" || strings.HasPrefix(base, "tutti-")) && !strings.HasPrefix(base, "tutti-connector-") {
|
|
candidates = append(candidates, base)
|
|
}
|
|
}
|
|
if len(candidates) == 0 {
|
|
return "tutti"
|
|
}
|
|
sort.SliceStable(candidates, func(left, right int) bool {
|
|
if candidates[left] == "tutti" {
|
|
return false
|
|
}
|
|
if candidates[right] == "tutti" {
|
|
return true
|
|
}
|
|
return candidates[left] < candidates[right]
|
|
})
|
|
return candidates[0]
|
|
}
|