1010from agentstack import packaging
1111from agentstack import frameworks
1212from agentstack import generation
13+ from agentstack import repo
1314from agentstack .templates import get_all_templates , TemplateConfig
1415
1516from agentstack .cli import welcome_message
@@ -76,24 +77,31 @@ def init_project(
7677 - install dependencies
7778 - insert Tasks, Agents and Tools
7879 """
79- require_uv ()
80-
8180 # TODO prevent the user from passing the --path argument to init
82- if slug_name :
83- if not is_snake_case (slug_name ):
84- raise Exception ("Project name must be snake_case" )
85- conf .set_path (conf .PATH / slug_name )
86- else :
87- raise Exception ("No project directory specified.\n Run `agentstack init <project_name>`" )
88-
89- if os .path .exists (conf .PATH ): # cookiecutter requires the directory to not exist
90- raise Exception (f"Directory already exists: { conf .PATH } " )
91-
9281 if template and use_wizard :
9382 raise Exception ("Template and wizard flags cannot be used together" )
9483
84+ require_uv ()
9585 welcome_message ()
9686
87+ if not slug_name :
88+ log .info (
89+ "Provide a project name. This will be used to create a new directory in the "
90+ "current path and will be used as the project name. 🐍 Must be snake_case."
91+ )
92+ slug_name = inquirer .text (
93+ message = "Project name (snake_case)" ,
94+ )
95+
96+ if not slug_name :
97+ raise Exception ("Project name cannot be empty" )
98+ if not is_snake_case (slug_name ):
99+ raise Exception ("Project name must be snake_case" )
100+
101+ conf .set_path (conf .PATH / slug_name )
102+ if os .path .exists (conf .PATH ): # cookiecutter requires the directory to not exist
103+ raise Exception (f"Directory already exists: { conf .PATH } " )
104+
97105 if use_wizard :
98106 log .debug ("Initializing new project with wizard." )
99107 template_data = run_wizard (slug_name )
@@ -120,18 +128,23 @@ def init_project(
120128 packaging .create_venv ()
121129 log .info ("Installing dependencies..." )
122130 packaging .install_project ()
131+ repo .init () # initialize git repo
123132
124133 # now we can interact with the project and add Agents, Tasks, and Tools
125134 # we allow dependencies to be installed along with these, so the project must
126135 # be fully initialized first.
127- for task in template_data .tasks :
128- generation .add_task (** task .model_dump ())
129-
130- for agent in template_data .agents :
131- generation .add_agent (** agent .model_dump ())
132-
133- for tool in template_data .tools :
134- generation .add_tool (** tool .model_dump ())
136+ with repo .Transaction () as commit :
137+ for task in template_data .tasks :
138+ commit .add_message (f"Added task { task .name } " )
139+ generation .add_task (** task .model_dump ())
140+
141+ for agent in template_data .agents :
142+ commit .add_message (f"Added agent { agent .name } " )
143+ generation .add_agent (** agent .model_dump ())
144+
145+ for tool in template_data .tools :
146+ commit .add_message (f"Added tool { tool .name } " )
147+ generation .add_tool (** tool .model_dump ())
135148
136149 log .success ("🚀 AgentStack project generated successfully!\n " )
137150 log .info (
0 commit comments