// Package auth provides authentication configuration for the copilot service.
// It manages application directories, token storage paths, and ensures proper setup.
package auth

import (
	"os"
	"path/filepath"
)

var (
	// gitHubTokenPath is the file path for storing GitHub authentication token
	gitHubTokenPath string
)

// init initializes configuration paths based on the user's home directory.
// It sets up the configuration directory and token file paths.
func init() {
	var configDir string
	home, err := os.UserHomeDir()
	if err != nil {
		// Use /etc/apr as a fallback if home directory cannot be determined
		configDir = "/etc/apr"
	} else {
		configDir = filepath.Join(home, ".config", "apr")
	}

	gitHubTokenPath = filepath.Join(configDir, "github_token")
}

// GitHubTokenPath returns the file path for storing GitHub authentication tokens.
// Exported for use by setup.go to read tokens before manager initialization.
func GitHubTokenPath() string {
	return gitHubTokenPath
}
