1919 CookiecutterData ,
2020)
2121from agentstack .logger import log
22+ from agentstack import conf
23+ from agentstack .conf import ConfigFile
2224from agentstack .utils import get_package_path
2325from agentstack .tools import get_all_tools
24- from agentstack .generation .files import ConfigFile , ProjectFile
26+ from agentstack .generation .files import ProjectFile
2527from agentstack import frameworks
2628from agentstack import generation
2729from agentstack import inputs
@@ -117,9 +119,12 @@ def init_project_builder(
117119
118120 log .debug (f"project_details: { project_details } " f"framework: { framework } " f"design: { design } " )
119121 insert_template (project_details , framework , design , template_data )
120- path = Path (project_details ['name' ])
122+
123+ # we have an agentstack.json file in the directory now
124+ conf .set_path (project_details ['name' ])
125+
121126 for tool_data in tools :
122- generation .add_tool (tool_data ['name' ], agents = tool_data ['agents' ], path = path )
127+ generation .add_tool (tool_data ['name' ], agents = tool_data ['agents' ])
123128
124129
125130def welcome_message ():
@@ -135,9 +140,9 @@ def welcome_message():
135140 print (border )
136141
137142
138- def configure_default_model (path : Optional [ str ] = None ):
143+ def configure_default_model ():
139144 """Set the default model"""
140- agentstack_config = ConfigFile (path )
145+ agentstack_config = ConfigFile ()
141146 if agentstack_config .default_model :
142147 return # Default model already set
143148
@@ -152,7 +157,7 @@ def configure_default_model(path: Optional[str] = None):
152157 print ('A list of available models is available at: "https://docs.litellm.ai/docs/providers"' )
153158 model = inquirer .text (message = "Enter the model name" )
154159
155- with ConfigFile (path ) as agentstack_config :
160+ with ConfigFile () as agentstack_config :
156161 agentstack_config .default_model = model
157162
158163
@@ -385,6 +390,7 @@ def insert_template(
385390 template_path = get_package_path () / f'templates/{ framework .name } '
386391 with open (f"{ template_path } /cookiecutter.json" , "w" ) as json_file :
387392 json .dump (cookiecutter_data .to_dict (), json_file )
393+ # TODO this should not be written to the package directory
388394
389395 # copy .env.example to .env
390396 shutil .copy (
@@ -453,22 +459,19 @@ def list_tools():
453459 print (" https://docs.agentstack.sh/tools/core" )
454460
455461
456- def export_template (output_filename : str , path : str = '' ):
462+ def export_template (output_filename : str ):
457463 """
458464 Export the current project as a template.
459465 """
460- _path = Path (path )
461- framework = get_framework (_path )
462-
463466 try :
464- metadata = ProjectFile (_path )
467+ metadata = ProjectFile ()
465468 except Exception as e :
466469 print (term_color (f"Failed to load project metadata: { e } " , 'red' ))
467470 sys .exit (1 )
468471
469472 # Read all the agents from the project's agents.yaml file
470473 agents : list [TemplateConfig .Agent ] = []
471- for agent in get_all_agents (_path ):
474+ for agent in get_all_agents ():
472475 agents .append (
473476 TemplateConfig .Agent (
474477 name = agent .name ,
@@ -481,7 +484,7 @@ def export_template(output_filename: str, path: str = ''):
481484
482485 # Read all the tasks from the project's tasks.yaml file
483486 tasks : list [TemplateConfig .Task ] = []
484- for task in get_all_tasks (_path ):
487+ for task in get_all_tasks ():
485488 tasks .append (
486489 TemplateConfig .Task (
487490 name = task .name ,
@@ -493,8 +496,8 @@ def export_template(output_filename: str, path: str = ''):
493496
494497 # Export all of the configured tools from the project
495498 tools_agents : dict [str , list [str ]] = {}
496- for agent_name in frameworks .get_agent_names (framework , _path ):
497- for tool_name in frameworks .get_agent_tool_names (framework , agent_name , _path ):
499+ for agent_name in frameworks .get_agent_names ():
500+ for tool_name in frameworks .get_agent_tool_names (agent_name ):
498501 if not tool_name :
499502 continue
500503 if tool_name not in tools_agents :
@@ -514,7 +517,7 @@ def export_template(output_filename: str, path: str = ''):
514517 template_version = 2 ,
515518 name = metadata .project_name ,
516519 description = metadata .project_description ,
517- framework = framework ,
520+ framework = get_framework () ,
518521 method = "sequential" , # TODO this needs to be stored in the project somewhere
519522 agents = agents ,
520523 tasks = tasks ,
@@ -523,8 +526,8 @@ def export_template(output_filename: str, path: str = ''):
523526 )
524527
525528 try :
526- template .write_to_file (_path / output_filename )
527- print (term_color (f"Template saved to: { _path / output_filename } " , 'green' ))
529+ template .write_to_file (conf . PATH / output_filename )
530+ print (term_color (f"Template saved to: { conf . PATH / output_filename } " , 'green' ))
528531 except Exception as e :
529532 print (term_color (f"Failed to write template to file: { e } " , 'red' ))
530533 sys .exit (1 )
0 commit comments