@@ -180,17 +180,35 @@ async function seedDefaultRecipes(): Promise<void> {
180180 ? path . join ( process . resourcesPath , 'default-recipes' )
181181 : path . join ( __dirname , '..' , 'default-recipes' ) ;
182182 const destDir = path . join ( os . homedir ( ) , '.config' , 'goose' , 'recipes' ) ;
183+ const hashesDir = path . join ( app . getPath ( 'userData' ) , 'recipe_hashes' ) ;
183184
184185 if ( ! fsSync . existsSync ( sourceRoot ) ) return ;
185186
186187 await fs . mkdir ( destDir , { recursive : true } ) ;
188+ await fs . mkdir ( hashesDir , { recursive : true } ) ;
187189 const entries = await fs . readdir ( sourceRoot ) ;
188190 for ( const entry of entries ) {
189191 if ( ! entry . endsWith ( '.yaml' ) && ! entry . endsWith ( '.yml' ) ) continue ;
192+ const sourcePath = path . join ( sourceRoot , entry ) ;
190193 const destPath = path . join ( destDir , entry ) ;
191- if ( fsSync . existsSync ( destPath ) ) continue ;
192- await fs . copyFile ( path . join ( sourceRoot , entry ) , destPath ) ;
193- log . info ( `[seedDefaultRecipes] seeded ${ entry } → ${ destPath } ` ) ;
194+
195+ if ( ! fsSync . existsSync ( destPath ) ) {
196+ await fs . copyFile ( sourcePath , destPath ) ;
197+ log . info ( `[seedDefaultRecipes] seeded ${ entry } → ${ destPath } ` ) ;
198+ }
199+
200+ try {
201+ const yamlContent = await fs . readFile ( sourcePath , 'utf-8' ) ;
202+ const parsed = yaml . parse ( yamlContent ) ;
203+ const hash = crypto . createHash ( 'sha256' ) . update ( JSON . stringify ( parsed ) ) . digest ( 'hex' ) ;
204+ const hashFile = path . join ( hashesDir , `${ hash } .hash` ) ;
205+ if ( ! fsSync . existsSync ( hashFile ) ) {
206+ await fs . writeFile ( hashFile , new Date ( ) . toISOString ( ) ) ;
207+ log . info ( `[seedDefaultRecipes] pre-trusted hash for ${ entry } → ${ hash } ` ) ;
208+ }
209+ } catch ( err ) {
210+ log . warn ( `[seedDefaultRecipes] failed to pre-trust ${ entry } :` , err ) ;
211+ }
194212 }
195213}
196214
0 commit comments