1- import { addMcpServers , AI_AGENT_LABELS , AI_AGENT_CHOICES , AIAgentTarget , copyAgentInstructionFiles , copyAISkillsToProject , GoogleAnalytics , InquirerWrapper , Util , AiCodingAssistant , AI_ASSISTANT_MCP_CONFIGS , AI_ASSISTANT_CHOICES , AI_ASSISTANT_LABELS } from "@igniteui/cli-core" ;
1+ import {
2+ addMcpServers ,
3+ AI_AGENT_LABELS ,
4+ AI_AGENT_CHOICES ,
5+ type AIAgentTarget ,
6+ copyAgentInstructionFiles ,
7+ copyAISkillsToProject ,
8+ GoogleAnalytics ,
9+ InquirerWrapper ,
10+ Util ,
11+ type AiCodingAssistant ,
12+ AI_ASSISTANT_MCP_CONFIGS ,
13+ AI_ASSISTANT_CHOICES ,
14+ AI_ASSISTANT_LABELS ,
15+ detectFramework ,
16+ App ,
17+ type BaseTemplateManager ,
18+ TEMPLATE_MANAGER ,
19+ } from "@igniteui/cli-core" ;
220import { ArgumentsCamelCase , CommandModule } from "yargs" ;
321
422export function configureMCP ( assistants : AiCodingAssistant [ ] ) : void {
@@ -14,8 +32,8 @@ export function configureMCP(assistants: AiCodingAssistant[]): void {
1432 }
1533}
1634
17- export function configureSkills ( agents : AIAgentTarget [ ] ) : void {
18- const result = copyAISkillsToProject ( agents ) ;
35+ export function configureSkills ( agents : AIAgentTarget [ ] , framework : string ) : void {
36+ const result = copyAISkillsToProject ( agents , framework ) ;
1937 if ( result . found === 0 ) {
2038 Util . warn ( "No AI skill files found. Make sure packages are installed (npm install) " +
2139 "and your Ignite UI packages are up-to-date." , "yellow" ) ;
@@ -32,7 +50,7 @@ export function configureSkills(agents: AIAgentTarget[]): void {
3250type AIAgentOption = AIAgentTarget | "none" ;
3351type AIAssistantOption = AiCodingAssistant | "none" ;
3452
35- export async function configure ( agents : AIAgentOption [ ] = [ ] , assistants : AIAssistantOption [ ] = [ ] , skills = true ) : Promise < { agents : AIAgentTarget [ ] , assistants : AiCodingAssistant [ ] } > {
53+ export async function configure ( framework : string , agents : AIAgentOption [ ] = [ ] , assistants : AIAssistantOption [ ] = [ ] , skills = true ) : Promise < { agents : AIAgentTarget [ ] , assistants : AiCodingAssistant [ ] } > {
3654 if ( ! agents . length ) {
3755 agents = await promptForAgents ( ) ;
3856 }
@@ -53,9 +71,9 @@ export async function configure(agents: AIAgentOption[] = [], assistants: AIAssi
5371 Util . log ( "No AI configuration selected. Skipping." ) ;
5472 } else {
5573 if ( skills ) {
56- configureSkills ( resolvedAgents ) ;
74+ configureSkills ( resolvedAgents , framework ) ;
5775 }
58- copyAgentInstructionFiles ( resolvedAgents ) ;
76+ copyAgentInstructionFiles ( resolvedAgents , framework ) ;
5977 }
6078
6179 return { agents : resolvedAgents , assistants : resolvedAssistants } ;
@@ -82,7 +100,7 @@ const AI_ASSISTANT_CHECKBOX_CHOICES = [
82100 } ) )
83101] ;
84102
85- export async function promptForAgents ( ) : Promise < AIAgentOption [ ] > {
103+ async function promptForAgents ( ) : Promise < AIAgentOption [ ] > {
86104 let selected : AIAgentOption [ ] = AI_AGENT_CHECKBOX_DEFAULTS ;
87105 if ( Util . canPrompt ( ) ) {
88106 const result = await InquirerWrapper . checkbox ( {
@@ -95,7 +113,7 @@ export async function promptForAgents(): Promise<AIAgentOption[]> {
95113 return selected ;
96114}
97115
98- export async function promptForAssistant ( ) : Promise < AIAssistantOption [ ] > {
116+ async function promptForAssistant ( ) : Promise < AIAssistantOption [ ] > {
99117 let selected : AIAssistantOption [ ] = AI_ASSISTANT_CHECKBOX_DEFAULTS ;
100118 if ( Util . canPrompt ( ) ) {
101119 const result = await InquirerWrapper . checkbox ( {
@@ -108,6 +126,23 @@ export async function promptForAssistant(): Promise<AIAssistantOption[]> {
108126 return selected ;
109127}
110128
129+ /** delayed call so it's not immediate on module import for testing purposes */
130+ function getTemplateManager ( ) : BaseTemplateManager {
131+ return App . container . get < BaseTemplateManager > ( TEMPLATE_MANAGER ) ;
132+ }
133+
134+ /** Separate from the PromptSession prompt due to step by step config */
135+ async function promptForFrameworkId ( ) : Promise < string > {
136+ const tm = getTemplateManager ( ) ;
137+ const frameRes : string = await InquirerWrapper . select ( {
138+ name : "framework" ,
139+ message : "Choose framework:" ,
140+ choices : tm . getFrameworkNames ( ) ,
141+ default : "Angular"
142+ } ) ;
143+ return tm . getFrameworkByName ( frameRes ) . id ;
144+ }
145+
111146const command : CommandModule = {
112147 command : "ai-config" ,
113148 describe : "Configures Ignite UI AI tooling (MCP servers, AI coding skills and instructions)" ,
@@ -122,6 +157,12 @@ const command: CommandModule = {
122157 describe : "Coding assistant(s) to configure MCP servers for" ,
123158 choices : [ ...AI_ASSISTANT_CHOICES , "none" ] as string [ ] ,
124159 type : "array"
160+ } )
161+ . option ( "framework" , {
162+ alias : "f" ,
163+ describe : "Manually set project framework to configure AI for." ,
164+ choices : getTemplateManager ( ) ?. getFrameworkIds ( ) ,
165+ type : "string"
125166 } ) ,
126167 async handler ( argv : ArgumentsCamelCase ) {
127168 const agents = ( argv . agents ?? [ ] ) as AIAgentOption [ ] ;
@@ -131,7 +172,20 @@ const command: CommandModule = {
131172 cd : "Ai Config"
132173 } ) ;
133174
134- const result = await configure ( agents , assistants ) ;
175+ let framework : string = argv . framework as string ?? detectFramework ( ) ;
176+ if ( ! framework ) {
177+ Util . log ( "Framework not provided and couldn't detect project from config or structure." ) ;
178+ if ( Util . canPrompt ( ) ) {
179+ framework = await promptForFrameworkId ( ) ;
180+ } else {
181+ return Util . error ( "Please provide --framework argument." , "red" ) ;
182+ }
183+ }
184+ if ( ! getTemplateManager ( ) ?. getFrameworkById ( framework ) ) {
185+ return Util . error ( "Framework not supported" , "red" ) ;
186+ }
187+
188+ const result = await configure ( framework , agents , assistants ) ;
135189
136190 GoogleAnalytics . post ( {
137191 t : "event" ,
0 commit comments