@@ -5,6 +5,11 @@ import { spawn } from "child_process";
5
5
import fs from "fs" ;
6
6
import path from "path" ;
7
7
8
+ // Import giget with proper typing
9
+ const { downloadTemplate } = require ( "giget" ) as {
10
+ downloadTemplate : ( template : string , options : { dir : string ; install : boolean } ) => Promise < void > ;
11
+ } ;
12
+
8
13
const program = new Command ( ) ;
9
14
10
15
// Dark purple color
@@ -41,6 +46,7 @@ async function createProject() {
41
46
message : "What client do you want to use?" ,
42
47
choices : [
43
48
"CopilotKit/Next.js" ,
49
+ "CLI client" ,
44
50
new inquirer . Separator ( "Other clients coming soon (SMS, Whatsapp, Slack ...)" ) ,
45
51
] ,
46
52
} ,
@@ -49,6 +55,13 @@ async function createProject() {
49
55
console . log ( `\nSelected client: ${ answers . client } ` ) ;
50
56
console . log ( "Initializing your project...\n" ) ;
51
57
58
+ // Handle CLI client option
59
+ if ( answers . client === "CLI client" ) {
60
+ await handleCliClient ( ) ;
61
+ return ;
62
+ }
63
+
64
+ // Continue with existing CopilotKit/Next.js logic
52
65
const packageJsonPath = path . join ( process . cwd ( ) , "package.json" ) ;
53
66
const packageJsonExists = fs . existsSync ( packageJsonPath ) ;
54
67
@@ -122,7 +135,7 @@ async function createProject() {
122
135
123
136
// Run copilotkit init with framework flags
124
137
console . log ( "\n🚀 Running CopilotKit initialization...\n" ) ;
125
-
138
+
126
139
const options = program . opts ( ) ;
127
140
const frameworkArgs = [ ] ;
128
141
@@ -154,6 +167,48 @@ async function createProject() {
154
167
} ) ;
155
168
}
156
169
170
+ async function handleCliClient ( ) {
171
+ console . log ( "🔧 Setting up CLI client...\n" ) ;
172
+
173
+ const projectName = await inquirer . prompt ( [
174
+ {
175
+ type : "input" ,
176
+ name : "name" ,
177
+ message : "What would you like to name your CLI project?" ,
178
+ default : "my-ag-ui-cli-app" ,
179
+ validate : ( input ) => {
180
+ if ( ! input . trim ( ) ) {
181
+ return "Project name cannot be empty" ;
182
+ }
183
+ if ( ! / ^ [ a - z A - Z 0 - 9 - _ ] + $ / . test ( input ) ) {
184
+ return "Project name can only contain letters, numbers, hyphens, and underscores" ;
185
+ }
186
+ return true ;
187
+ } ,
188
+ } ,
189
+ ] ) ;
190
+
191
+ try {
192
+ console . log ( `📥 Downloading CLI client template: ${ projectName . name } \n` ) ;
193
+
194
+ await downloadTemplate ( "gh:ag-ui-protocol/ag-ui/typescript-sdk/apps/client-cli-example" , {
195
+ dir : projectName . name ,
196
+ install : false ,
197
+ } ) ;
198
+
199
+ console . log ( "✅ CLI client template downloaded successfully!" ) ;
200
+ console . log ( `\n📁 Project created in: ${ projectName . name } ` ) ;
201
+ console . log ( "\n🚀 Next steps:" ) ;
202
+ console . log ( ` cd ${ projectName . name } ` ) ;
203
+ console . log ( " npm install" ) ;
204
+ console . log ( " npm run dev" ) ;
205
+ console . log ( "\n💡 Check the README.md for more information on how to use your CLI client!" ) ;
206
+ } catch ( error ) {
207
+ console . log ( "❌ Failed to download CLI client template:" , error ) ;
208
+ process . exit ( 1 ) ;
209
+ }
210
+ }
211
+
157
212
program . name ( "create-ag-ui-app" ) . description ( "AG-UI CLI" ) . version ( "0.0.1-alpha.1" ) ;
158
213
159
214
// Add framework flags
@@ -166,7 +221,6 @@ program
166
221
. option ( "--llamaindex" , "Use the LlamaIndex framework" )
167
222
. option ( "--agno" , "Use the Agno framework" ) ;
168
223
169
-
170
224
program . action ( async ( ) => {
171
225
await createProject ( ) ;
172
226
} ) ;
0 commit comments