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,12 @@ 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 [ ] } > {
54+ if ( framework === "jquery" ) {
55+ // currently not supported
56+ return { agents : [ ] , assistants : [ ] } ;
57+ }
58+
3659 if ( ! agents . length ) {
3760 agents = await promptForAgents ( ) ;
3861 }
@@ -53,9 +76,9 @@ export async function configure(agents: AIAgentOption[] = [], assistants: AIAssi
5376 Util . log ( "No AI configuration selected. Skipping." ) ;
5477 } else {
5578 if ( skills ) {
56- configureSkills ( resolvedAgents ) ;
79+ configureSkills ( resolvedAgents , framework ) ;
5780 }
58- copyAgentInstructionFiles ( resolvedAgents ) ;
81+ copyAgentInstructionFiles ( resolvedAgents , framework ) ;
5982 }
6083
6184 return { agents : resolvedAgents , assistants : resolvedAssistants } ;
@@ -82,7 +105,7 @@ const AI_ASSISTANT_CHECKBOX_CHOICES = [
82105 } ) )
83106] ;
84107
85- export async function promptForAgents ( ) : Promise < AIAgentOption [ ] > {
108+ async function promptForAgents ( ) : Promise < AIAgentOption [ ] > {
86109 let selected : AIAgentOption [ ] = AI_AGENT_CHECKBOX_DEFAULTS ;
87110 if ( Util . canPrompt ( ) ) {
88111 const result = await InquirerWrapper . checkbox ( {
@@ -95,7 +118,7 @@ export async function promptForAgents(): Promise<AIAgentOption[]> {
95118 return selected ;
96119}
97120
98- export async function promptForAssistant ( ) : Promise < AIAssistantOption [ ] > {
121+ async function promptForAssistant ( ) : Promise < AIAssistantOption [ ] > {
99122 let selected : AIAssistantOption [ ] = AI_ASSISTANT_CHECKBOX_DEFAULTS ;
100123 if ( Util . canPrompt ( ) ) {
101124 const result = await InquirerWrapper . checkbox ( {
@@ -108,6 +131,23 @@ export async function promptForAssistant(): Promise<AIAssistantOption[]> {
108131 return selected ;
109132}
110133
134+ /** delayed call so it's not immediate on module import for testing purposes */
135+ function getTemplateManager ( ) : BaseTemplateManager {
136+ return App . container . get < BaseTemplateManager > ( TEMPLATE_MANAGER ) ;
137+ }
138+
139+ /** Separate from the PromptSession prompt due to step by step config */
140+ async function promptForFrameworkId ( ) : Promise < string > {
141+ const tm = getTemplateManager ( ) ;
142+ const frameRes : string = await InquirerWrapper . select ( {
143+ name : "framework" ,
144+ message : "Choose framework:" ,
145+ choices : tm . getFrameworkNames ( true ) ,
146+ default : "Angular"
147+ } ) ;
148+ return tm . getFrameworkByName ( frameRes ) . id ;
149+ }
150+
111151const command : CommandModule = {
112152 command : "ai-config" ,
113153 describe : "Configures Ignite UI AI tooling (MCP servers, AI coding skills and instructions)" ,
@@ -122,6 +162,12 @@ const command: CommandModule = {
122162 describe : "Coding assistant(s) to configure MCP servers for" ,
123163 choices : [ ...AI_ASSISTANT_CHOICES , "none" ] as string [ ] ,
124164 type : "array"
165+ } )
166+ . option ( "framework" , {
167+ alias : "f" ,
168+ describe : "Manually set project framework to configure AI for." ,
169+ choices : getTemplateManager ( ) ?. getFrameworkIds ( true ) ,
170+ type : "string"
125171 } ) ,
126172 async handler ( argv : ArgumentsCamelCase ) {
127173 const agents = ( argv . agents ?? [ ] ) as AIAgentOption [ ] ;
@@ -131,12 +177,30 @@ const command: CommandModule = {
131177 cd : "Ai Config"
132178 } ) ;
133179
134- const result = await configure ( agents , assistants ) ;
180+ let framework : string = argv . framework as string ?? detectFramework ( ) ;
181+ if ( ! framework ) {
182+ Util . log ( "Framework not provided and couldn't detect project from config or structure." ) ;
183+ if ( Util . canPrompt ( ) ) {
184+ framework = await promptForFrameworkId ( ) ;
185+ } else {
186+ return Util . error ( "Please provide --framework argument." , "red" ) ;
187+ }
188+ }
189+ if ( ! getTemplateManager ( ) ?. getFrameworkById ( framework ) ) {
190+ return Util . error ( "Framework not supported" , "red" ) ;
191+ }
192+
193+ if ( framework === "jquery" ) {
194+ Util . log ( "AI Config currently not available for jQuery projects." ) ;
195+ }
196+
197+ const result = await configure ( framework , agents , assistants ) ;
135198
136199 GoogleAnalytics . post ( {
137200 t : "event" ,
138201 ec : "$ig ai-config" ,
139- ea : `agent: ${ result . agents . join ( ", " ) || "none" } ; assistant: ${ result . assistants . join ( ", " ) || "none" } `
202+ ea : `agent: ${ result . agents . join ( ", " ) || "none" } ; assistant: ${ result . assistants . join ( ", " ) || "none" } ` ,
203+ cd1 : framework
140204 } ) ;
141205 }
142206} ;
0 commit comments