Files
tutti/services/tuttid/service/workspace/app_shell_adapter_windows.go
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

58 lines
1.6 KiB
Go

//go:build windows
package workspace
import (
"context"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
)
const managedPosixShellEnv = "TUTTI_MANAGED_POSIX_SHELL"
func (platformAppShellAdapter) ValidateScript(scriptPath string) error {
info, err := os.Stat(scriptPath)
if err != nil {
return err
}
if info.IsDir() {
return fmt.Errorf("must be a file")
}
return nil
}
func (platformAppShellAdapter) Command(ctx context.Context, scriptPath string) (*exec.Cmd, []string, error) {
shellPath := strings.TrimSpace(os.Getenv(managedPosixShellEnv))
if shellPath == "" {
return nil, nil, fmt.Errorf("managed POSIX shell is unavailable on Windows: %s is not configured", managedPosixShellEnv)
}
if !filepath.IsAbs(shellPath) {
return nil, nil, fmt.Errorf("managed POSIX shell must be an absolute path: %s", shellPath)
}
info, err := os.Stat(shellPath)
if err != nil {
return nil, nil, fmt.Errorf("stat managed POSIX shell: %w", err)
}
if info.IsDir() {
return nil, nil, fmt.Errorf("managed POSIX shell must be a file: %s", shellPath)
}
return exec.CommandContext(ctx, shellPath, "--noprofile", "--norc", scriptPath), []string{filepath.Dir(shellPath)}, nil
}
func (platformAppShellAdapter) EnvironmentOverrides() []string {
shellPath := strings.TrimSpace(os.Getenv(managedPosixShellEnv))
if shellPath == "" {
return nil
}
// The app process receives a deliberately filtered environment. Preserve the
// managed shell contract explicitly so nested scripts and MSYS2 do not have
// to infer the shell from PATH alone.
return []string{
managedPosixShellEnv + "=" + shellPath,
"MSYS2_PATH_TYPE=inherit",
}
}