@@ -40,15 +40,18 @@ function createDefaultMcpDefs(): AgentCoreCliMcpDefs {
4040 return { tools : { } } ;
4141}
4242
43+ export type ProgressCallback = ( step : string , status : 'start' | 'done' | 'error' ) => void ;
44+
4345export interface CreateProjectOptions {
4446 name : string ;
4547 cwd : string ;
4648 skipGit ?: boolean ;
4749 skipDependencyCheck ?: boolean ;
50+ onProgress ?: ProgressCallback ;
4851}
4952
5053export async function createProject ( options : CreateProjectOptions ) : Promise < CreateResult > {
51- const { name, cwd, skipGit, skipDependencyCheck } = options ;
54+ const { name, cwd, skipGit, skipDependencyCheck, onProgress } = options ;
5255 const projectRoot = join ( cwd , name ) ;
5356 const configBaseDir = join ( projectRoot , CONFIG_DIR ) ;
5457
@@ -66,10 +69,13 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
6669
6770 try {
6871 // Create project directory
72+ onProgress ?.( `Create ${ name } / project directory` , 'start' ) ;
6973 // eslint-disable-next-line security/detect-non-literal-fs-filename
7074 await mkdir ( projectRoot , { recursive : true } ) ;
75+ onProgress ?.( `Create ${ name } / project directory` , 'done' ) ;
7176
7277 // Initialize config directory
78+ onProgress ?.( 'Prepare agentcore/ directory' , 'start' ) ;
7379 const configIO = new ConfigIO ( { baseDir : configBaseDir } ) ;
7480 await configIO . initializeBaseDir ( ) ;
7581
@@ -87,13 +93,17 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
8793 // Create CDK project
8894 const cdkRenderer = new CDKRenderer ( ) ;
8995 await cdkRenderer . render ( { projectRoot } ) ;
96+ onProgress ?.( 'Prepare agentcore/ directory' , 'done' ) ;
9097
9198 // Initialize git (unless skipped)
9299 if ( ! skipGit ) {
100+ onProgress ?.( 'Initialize git repository' , 'start' ) ;
93101 const gitResult = await initGitRepo ( projectRoot ) ;
94102 if ( gitResult . status === 'error' ) {
103+ onProgress ?.( 'Initialize git repository' , 'error' ) ;
95104 return { success : false , error : gitResult . message , warnings : depWarnings } ;
96105 }
106+ onProgress ?.( 'Initialize git repository' , 'done' ) ;
97107 }
98108
99109 return {
@@ -118,10 +128,12 @@ export interface CreateWithAgentOptions {
118128 memory : MemoryOption ;
119129 skipGit ?: boolean ;
120130 skipPythonSetup ?: boolean ;
131+ onProgress ?: ProgressCallback ;
121132}
122133
123134export async function createProjectWithAgent ( options : CreateWithAgentOptions ) : Promise < CreateResult > {
124- const { name, cwd, language, framework, modelProvider, apiKey, memory, skipGit, skipPythonSetup } = options ;
135+ const { name, cwd, language, framework, modelProvider, apiKey, memory, skipGit, skipPythonSetup, onProgress } =
136+ options ;
125137 const projectRoot = join ( cwd , name ) ;
126138 const configBaseDir = join ( projectRoot , CONFIG_DIR ) ;
127139
@@ -135,7 +147,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
135147 }
136148
137149 // First create the base project (skip dependency check since we already did it)
138- const projectResult = await createProject ( { name, cwd, skipGit, skipDependencyCheck : true } ) ;
150+ const projectResult = await createProject ( { name, cwd, skipGit, skipDependencyCheck : true , onProgress } ) ;
139151 if ( ! projectResult . success ) {
140152 // Merge warnings from both checks
141153 const allWarnings = [ ...depWarnings , ...( projectResult . warnings ?? [ ] ) ] ;
@@ -145,6 +157,7 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
145157 try {
146158 // Build GenerateConfig for agent creation
147159 // Note: In this context, agent name = project name since we're creating a project with a single agent
160+ onProgress ?.( 'Add agent to project' , 'start' ) ;
148161 const agentName = name ;
149162 const generateConfig = {
150163 projectName : agentName ,
@@ -168,11 +181,14 @@ export async function createProjectWithAgent(options: CreateWithAgentOptions): P
168181 const envVarName = computeDefaultCredentialEnvVarName ( credentialName ) ;
169182 await setEnvVar ( envVarName , apiKey , configBaseDir ) ;
170183 }
184+ onProgress ?.( 'Add agent to project' , 'done' ) ;
171185
172186 // Set up Python environment if needed (unless skipped)
173187 if ( language === 'Python' && ! skipPythonSetup ) {
188+ onProgress ?.( 'Set up Python environment' , 'start' ) ;
174189 const agentDir = join ( projectRoot , APP_DIR , name ) ;
175190 await setupPythonProject ( { projectDir : agentDir } ) ;
191+ onProgress ?.( 'Set up Python environment' , 'done' ) ;
176192 }
177193
178194 return {
0 commit comments