@@ -826,6 +826,9 @@ export class Controller {
826826 case "loadExperts" :
827827 await this . loadExperts ( )
828828 break
829+ case "loadDefaultExperts" :
830+ await this . loadDefaultExperts ( )
831+ break
829832 case "refreshDocumentLink" :
830833 if ( message . text && message . expert ) {
831834 await this . expertManager . refreshDocumentLink ( this . vsCodeWorkSpaceFolderFsPath , message . expert , message . text )
@@ -962,6 +965,44 @@ export class Controller {
962965 break
963966 }
964967 break
968+ case "writeTaskStatus" :
969+ // write status to the file
970+ const folder = message . folder
971+ const taskId = message ?. taskId ?? ""
972+ const status = message ?. status
973+ const taskIdMatch = taskId . match ( / ^ ( \d + ) - U S ( \d + ) - T A S K ( \d + ) $ / )
974+ if ( ! folder || ! taskIdMatch || ! status ) {
975+ const message = `Failed to update task status. Error: Either folder, taskId or status is invalid.`
976+ vscode . window . showErrorMessage ( message )
977+ } else {
978+ const [ _ , prdId , usId , taskId ] = taskIdMatch
979+ const prdFeatureFilePath = path . join ( `${ folder } ` , "PRD" , `PRD${ prdId } -feature.json` )
980+ try {
981+ const fileContent = await fs . readFile ( prdFeatureFilePath , "utf-8" )
982+ const prdFeatureJson = JSON . parse ( fileContent )
983+ const feature = prdFeatureJson [ "features" ] . find ( ( feature : { id : string } ) => feature . id === `US${ usId } ` )
984+ if ( feature ) {
985+ const selectedTask = feature [ "tasks" ] . find ( ( task : { id : string } ) => task . id === `TASK${ taskId } ` )
986+ selectedTask . status = status
987+ }
988+
989+ await fs . writeFile ( prdFeatureFilePath , JSON . stringify ( prdFeatureJson , null , 2 ) , "utf-8" )
990+ const message = `Successfully marked task as ${ status . toLowerCase ( ) } .`
991+ vscode . window . showInformationMessage ( message )
992+ await this . postMessageToWebview ( {
993+ type : "writeTaskStatus" ,
994+ writeTaskStatusResult : {
995+ success : true ,
996+ message,
997+ status,
998+ } ,
999+ } )
1000+ } catch ( error ) {
1001+ const message = `Failed to mark task as ${ status . toLowerCase ( ) } . Error: ${ error . message } `
1002+ vscode . window . showErrorMessage ( message )
1003+ }
1004+ }
1005+ break
9651006 default :
9661007 this . customWebViewMessageHandlers ( message )
9671008 break
@@ -2457,7 +2498,13 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
24572498 . filter ( ( file : string ) => file . match ( / \- f e a t u r e .j s o n $ / ) )
24582499 . forEach ( ( file : string ) => {
24592500 const content = fs . readFileSync ( path . join ( `${ url } /PRD` , file ) , "utf-8" )
2460- haiTaskList = [ ...haiTaskList , ...JSON . parse ( content ) . features ]
2501+ const prdId = file . split ( "-" ) [ 0 ] . replace ( "PRD" , "" )
2502+ const parsedFeaturesList = JSON . parse ( content ) . features
2503+ const featuresListWithPrdId = parsedFeaturesList . map ( ( feature : any ) => ( {
2504+ ...feature ,
2505+ prdId : prdId ,
2506+ } ) )
2507+ haiTaskList = [ ...haiTaskList , ...featuresListWithPrdId ]
24612508 } )
24622509 return haiTaskList
24632510 } catch ( e ) {
@@ -2570,6 +2617,14 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
25702617 } )
25712618 }
25722619
2620+ async loadDefaultExperts ( ) {
2621+ const experts = await this . expertManager . loadDefaultExperts ( )
2622+ await this . postMessageToWebview ( {
2623+ type : "defaultExpertsLoaded" ,
2624+ experts,
2625+ } )
2626+ }
2627+
25732628 private async getExpertDocumentsContent ( expertName : string ) : Promise < string > {
25742629 const expertPath = await this . expertManager . getExpertPromptPath ( this . vsCodeWorkSpaceFolderFsPath , expertName )
25752630
0 commit comments