@@ -30,7 +30,7 @@ export interface OS {
3030/**
3131 * Get the path to the Goose config file based on the current operating system
3232 * @param os The OS module to use (for testing)
33- * @returns The path to the config file, or null if the platform isn't supported
33+ * @returns The path to the config file, or null if the platform isn't supported or APPDATA is missing on Windows.
3434 */
3535export function getConfigPath ( os : OS = osDefault ) : string | null {
3636 const homeDir = os . homedir ( ) ;
@@ -42,9 +42,10 @@ export function getConfigPath(os: OS = osDefault): string | null {
4242 const appData = process . env . APPDATA ;
4343 if ( ! appData ) {
4444 logger . error ( 'Could not determine APPDATA directory on Windows.' ) ;
45- return null ;
45+ return null ; // Return null if APPDATA is not set
4646 }
47- configPath = path . join ( homeDir , 'AppData' , 'Roaming' , 'Block' , 'goose' , 'config' , 'config.yaml' ) ;
47+ // Use appData instead of homeDir for the base path on Windows
48+ configPath = path . join ( appData , 'Block' , 'goose' , 'config' , 'config.yaml' ) ;
4849 break ;
4950 case 'darwin' : // macOS
5051 case 'linux' :
@@ -59,7 +60,7 @@ export function getConfigPath(os: OS = osDefault): string | null {
5960 * Read and parse the Goose configuration file
6061 * @param fs Optional file system implementation for testing
6162 * @param os Optional OS implementation for testing
62- * @returns A GooseConfig object containing provider and model, or null values if not found
63+ * @returns A GooseConfig object containing provider and model, or null values if not found or on error.
6364 */
6465export function readGooseConfig ( fs : FileSystem = fsDefault , os : OS = osDefault ) : GooseConfig {
6566 const defaultConfig : GooseConfig = { provider : null , model : null } ;
@@ -79,12 +80,12 @@ export function readGooseConfig(fs: FileSystem = fsDefault, os: OS = osDefault):
7980 }
8081
8182 const fileContents = fs . readFileSync ( configPath , 'utf8' ) ;
82-
83+
8384 // Handle both string and buffer return types
84- const contentStr = typeof fileContents === 'string'
85- ? fileContents
85+ const contentStr = typeof fileContents === 'string'
86+ ? fileContents
8687 : fileContents . toString ( 'utf8' ) ;
87-
88+
8889 const config = YAML . parse ( contentStr ) as any ; // Use 'any' for flexibility, validate below
8990
9091 if ( typeof config !== 'object' || config === null ) {
@@ -97,9 +98,10 @@ export function readGooseConfig(fs: FileSystem = fsDefault, os: OS = osDefault):
9798
9899 if ( ! provider ) {
99100 logger . warn ( 'GOOSE_PROVIDER key not found or invalid in config file.' ) ;
101+ // Don't return early, still check for model
100102 }
101103 if ( ! model ) {
102- logger . warn ( 'GOOSE_MODEL key not found or invalid in config file.' ) ;
104+ logger . warn ( 'GOOSE_MODEL key not found or invalid in config file.' ) ;
103105 }
104106
105107 logger . info ( `Loaded config: Provider=${ provider ?? 'MISSING' } , Model=${ model ?? 'MISSING' } ` ) ;
@@ -112,3 +114,13 @@ export function readGooseConfig(fs: FileSystem = fsDefault, os: OS = osDefault):
112114 return defaultConfig ; // Return nulls on error (file read/parse error)
113115 }
114116}
117+
118+ /**
119+ * Gets the determined path to the configuration file.
120+ * This is essentially a wrapper around getConfigPath for clarity.
121+ * @param os Optional OS implementation for testing
122+ * @returns The config file path string, or null if not found/determined.
123+ */
124+ export function getConfigFilePath ( os : OS = osDefault ) : string | null {
125+ return getConfigPath ( os ) ;
126+ }
0 commit comments