@@ -159,6 +159,7 @@ def main():
159159
160160 # Handle commands
161161 try :
162+ # outside of project
162163 if args .command in ["docs" ]:
163164 webbrowser .open ("https://docs.agentstack.sh/" )
164165 elif args .command in ["quickstart" ]:
@@ -167,36 +168,43 @@ def main():
167168 webbrowser .open ("https://docs.agentstack.sh/quickstart" )
168169 elif args .command in ["init" , "i" ]:
169170 init_project_builder (args .slug_name , args .template , args .wizard )
170- elif args .command in ["run" , "r" ]:
171- run_project (command = args .function , debug = args .debug , cli_args = extra_args )
172- elif args .command in ['generate' , 'g' ]:
173- if args .generate_command in ['agent' , 'a' ]:
174- if not args .llm :
175- configure_default_model ()
176- generation .add_agent (args .name , args .role , args .goal , args .backstory , args .llm )
177- elif args .generate_command in ['task' , 't' ]:
178- generation .add_task (args .name , args .description , args .expected_output , args .agent )
179- else :
180- generate_parser .print_help ()
181171 elif args .command in ["tools" , "t" ]:
182172 if args .tools_command in ["list" , "l" ]:
183173 list_tools ()
184174 elif args .tools_command in ["add" , "a" ]:
175+ conf .assert_project ()
185176 agents = [args .agent ] if args .agent else None
186177 agents = args .agents .split ("," ) if args .agents else agents
187178 add_tool (args .name , agents )
188179 elif args .tools_command in ["remove" , "r" ]:
180+ conf .assert_project ()
189181 generation .remove_tool (args .name )
190182 else :
191183 tools_parser .print_help ()
192- elif args .command in ['export' , 'e' ]:
193- export_template (args .filename )
194184 elif args .command in ['login' ]:
195185 auth .login ()
196186 elif args .command in ['update' , 'u' ]:
197187 pass # Update check already done
188+
189+ # inside project dir commands only
190+ conf .assert_project ()
191+
192+ if args .command in ["run" , "r" ]:
193+ run_project (command = args .function , debug = args .debug , cli_args = extra_args )
194+ elif args .command in ['generate' , 'g' ]:
195+ if args .generate_command in ['agent' , 'a' ]:
196+ if not args .llm :
197+ configure_default_model ()
198+ generation .add_agent (args .name , args .role , args .goal , args .backstory , args .llm )
199+ elif args .generate_command in ['task' , 't' ]:
200+ generation .add_task (args .name , args .description , args .expected_output , args .agent )
201+ else :
202+ generate_parser .print_help ()
203+ elif args .command in ['export' , 'e' ]:
204+ export_template (args .filename )
198205 else :
199206 parser .print_help ()
207+
200208 except Exception as e :
201209 update_telemetry (telemetry_id , result = 1 , message = str (e ))
202210 print (term_color ("An error occurred while running your AgentStack command:" , "red" ))
0 commit comments