package config import ( "os" "path/filepath" "strings" ) // ResolveRoot returns the absolute workspace root path. // Reads CTASK_ROOT env var, falls back to ~/ai-workspaces (or %USERPROFILE%\ai-workspaces on Windows). func ResolveRoot() string { root := os.Getenv("CTASK_ROOT") if root == "" { home, _ := os.UserHomeDir() return filepath.Join(home, "ai-workspaces") } // Expand leading tilde if strings.HasPrefix(root, "~/") || root == "~" { home, _ := os.UserHomeDir() root = filepath.Join(home, root[2:]) } abs, err := filepath.Abs(root) if err != nil { return root } return abs } // ResolveAgent returns the agent command. // Reads CTASK_AGENT env var, falls back to "claude". func ResolveAgent() string { agent := os.Getenv("CTASK_AGENT") if agent == "" { return "claude" } return agent } // EnvVars returns the environment variables to export into child sessions. func EnvVars(slug, mode, root, workspace, category string) map[string]string { return map[string]string{ "CTASK_TASK": slug, "CTASK_MODE": mode, "CTASK_ROOT": root, "CTASK_WORKSPACE": workspace, "CTASK_CATEGORY": category, } }