31 lines
713 B
Go
31 lines
713 B
Go
package workspace
|
|
|
|
import (
|
|
"cursor-api-proxy/internal/config"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
type WorkspaceResult struct {
|
|
WorkspaceDir string
|
|
TempDir string
|
|
}
|
|
|
|
func ResolveWorkspace(cfg config.BridgeConfig, workspaceHeader string) WorkspaceResult {
|
|
if cfg.ChatOnlyWorkspace {
|
|
tempDir, err := os.MkdirTemp("", "cursor-proxy-")
|
|
if err != nil {
|
|
tempDir = filepath.Join(os.TempDir(), "cursor-proxy-fallback")
|
|
_ = os.MkdirAll(tempDir, 0700)
|
|
}
|
|
return WorkspaceResult{WorkspaceDir: tempDir, TempDir: tempDir}
|
|
}
|
|
|
|
headerWs := strings.TrimSpace(workspaceHeader)
|
|
if headerWs != "" {
|
|
return WorkspaceResult{WorkspaceDir: headerWs}
|
|
}
|
|
return WorkspaceResult{WorkspaceDir: cfg.Workspace}
|
|
}
|