@@ -186,9 +186,9 @@ async function detectAndDisplayStructure(cwd: string): Promise<LangiumProjectStr
186186 *
187187 * @throws When config cannot be initialized successfully
188188 */
189- async function initConfig ( cwd : string , structure : LangiumProjectStructure , languageName : string ) : Promise < void > {
190- // normalize the language name in case we pickup a problematic name
191- const normalizedLanguageName = languageName . replaceAll ( / @ | \/ | \\ / g, '' ) ;
189+ async function initConfig ( cwd : string , structure : LangiumProjectStructure , projectName : string ) : Promise < void > {
190+ // normalize the project name in case we pickup a problematic name
191+ const normalizedProjectName = projectName . replaceAll ( / @ | \/ | \\ / g, '' ) ;
192192
193193 const config : LaiConfig = {
194194 // TODO need to adjust this so it's either the language version or LAI version, can't be both
@@ -204,16 +204,16 @@ async function initConfig(cwd: string, structure: LangiumProjectStructure, langu
204204 } ) ,
205205 } ,
206206 descriptor : {
207- path : `${ normalizedLanguageName } .descriptor.yml` ,
207+ path : `${ normalizedProjectName } .descriptor.yml` ,
208208 } ,
209209 sysprompt : {
210- path : `${ normalizedLanguageName } .sysprompt.md` ,
210+ path : `${ normalizedProjectName } .sysprompt.md` ,
211211 } ,
212212 evaluations : {
213213 directory : 'evals' ,
214214 } ,
215215 project : {
216- name : languageName ,
216+ name : projectName ,
217217 } ,
218218 } ;
219219
@@ -355,18 +355,17 @@ export async function initCommand(options: InitOptions = {}): Promise<void> {
355355 }
356356
357357 // interactive configuration (defaults are used automatically in non-interactive mode)
358- const projectName = getProjectName ( structure ) ;
359- const projectNameInput = yes ? projectName : await text ( 'Project name' , projectName ) ;
358+ const defaultProjectName : string = getProjectName ( structure ) ;
359+ const projectName : string =
360+ ( yes ? defaultProjectName : await text ( 'Project name' , defaultProjectName ) ) ?? defaultProjectName ;
360361
361- if ( ! projectNameInput ) {
362+ if ( ! projectName ) {
362363 console . log ( 'Initialization cancelled.' ) ;
363364 return ;
364365 }
365366
366- const languageName = projectNameInput ;
367-
368367 // create config
369- await initConfig ( cwd , structure , languageName ) ;
368+ await initConfig ( cwd , structure , projectName ) ;
370369
371370 // offer to install langium-ai-tools
372371 const pm = await detectPackageManager ( cwd ) ;
0 commit comments