@@ -169,7 +169,7 @@ export class TaskMaster {
169169 * by encapsulating the 'tasks' and 'metadata' keys under a 'master' key
170170 * @param mode Operation mode: 'init' for initialization or 'repair' for fixing existing file
171171 */
172- public async _fixTasksFileFormatAsync (
172+ private async _fixTasksFileFormatAsync (
173173 mode : "init" | "repair" = "repair" ,
174174 ) : Promise < void > {
175175 const isInitMode = mode === "init" ;
@@ -318,6 +318,65 @@ export class TaskMaster {
318318 ) ;
319319 }
320320
321+ // TODO: done
322+ /**
323+ * @description Validates that tasks are ready (file exists and has at least one task)
324+ * @returns True if tasks are ready, false otherwise
325+ */
326+ public async validateTasksReadyAsync ( ) : Promise < boolean > {
327+ // Check if tasks.json file exists
328+ if ( ! fs . existsSync ( this . _tasksFilePath ) ) {
329+ console . log (
330+ chalk . yellow (
331+ "TMAI is not initialized. Please run the initialization process and generate at least one task." ,
332+ ) ,
333+ ) ;
334+ await this . countdownAsync ( 10 ) ;
335+ return false ;
336+ }
337+
338+ try {
339+ // Read the tasks file
340+ const tasks = await this . getTasksContentAsync ( ) ;
341+
342+ // Check if tasks object and master property exist
343+ if ( ! tasks || ! tasks . master ) {
344+ console . log (
345+ chalk . yellow (
346+ "TMAI is not initialized. Please run the initialization process and generate at least one task." ,
347+ ) ,
348+ ) ;
349+ await this . countdownAsync ( 10 ) ;
350+ return false ;
351+ }
352+
353+ // Check if there's at least one task in master.tasks
354+ if (
355+ ! tasks . master . tasks ||
356+ ! Array . isArray ( tasks . master . tasks ) ||
357+ tasks . master . tasks . length === 0
358+ ) {
359+ console . log (
360+ chalk . yellow (
361+ "TMAI is not initialized. Please generate at least one task." ,
362+ ) ,
363+ ) ;
364+ await this . countdownAsync ( 10 ) ;
365+ return false ;
366+ }
367+
368+ return true ;
369+ } catch {
370+ console . log (
371+ chalk . yellow (
372+ "TMAI is not initialized. Please run the initialization process and generate at least one task." ,
373+ ) ,
374+ ) ;
375+ await this . countdownAsync ( 10 ) ;
376+ return false ;
377+ }
378+ }
379+
321380 // TODO: done
322381 /**
323382 * @description Fixes the IDs of all tasks and subtasks in tasks.json to be sequential
@@ -662,6 +721,7 @@ export class TaskMaster {
662721
663722 await runCommandAsync ( this . _mainCommand , [ "init" ] , false , false ) ;
664723 console . log ( chalk . bgGreen ( "Task-master project initialized successfully!" ) ) ;
724+ await this . _fixTasksFileFormatAsync ( "init" ) ;
665725 }
666726
667727 // TODO: done
@@ -670,7 +730,7 @@ export class TaskMaster {
670730 */
671731 public async interactiveConfigModelAsync ( ) : Promise < void > {
672732 await this . _executeCommandAsync (
673- "Configuring AI models..." ,
733+ "Configuring AI models...\n " ,
674734 "AI models configured successfully!" ,
675735 "AI model configuration failed" ,
676736 this . _mainCommand ,
@@ -693,7 +753,7 @@ export class TaskMaster {
693753 provider ?: string ,
694754 ) : Promise < void > {
695755 const oraOptions = {
696- text : "Configuring AI models..." ,
756+ text : "Configuring AI models...\n " ,
697757 successText : chalk . bgGreen ( "AI models configured successfully!" ) ,
698758 failText : chalk . bgRed ( "AI model configuration failed" ) ,
699759 } ;
0 commit comments