Skip to content

Commit 4fbb651

Browse files
committed
Merge branch 'main' into templates-config
2 parents 13a6e33 + fb3af36 commit 4fbb651

File tree

5 files changed

+36
-18
lines changed

5 files changed

+36
-18
lines changed

agentstack/cli/cli.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,9 @@ def init_project_builder(
113113

114114
log.debug(f"project_details: {project_details}" f"framework: {framework}" f"design: {design}")
115115
insert_template(project_details, framework, design, template_data)
116+
path = Path(project_details['name'])
116117
for tool_data in tools:
117-
generation.add_tool(tool_data['name'], agents=tool_data['agents'], path=project_details['name'])
118-
119-
try:
120-
packaging.install(f'{AGENTSTACK_PACKAGE}[{framework}]', path=slug_name)
121-
except Exception:
122-
print(
123-
term_color(
124-
f"Failed to install dependencies for {slug_name}. Please try again by running `agentstack update`",
125-
'red',
126-
)
127-
)
118+
generation.add_tool(tool_data['name'], agents=tool_data['agents'], path=path)
128119

129120

130121
def welcome_message():
@@ -382,7 +373,9 @@ def insert_template(
382373
design: dict,
383374
template_data: Optional[TemplateConfig] = None,
384375
):
385-
framework = FrameworkData(framework_name.lower())
376+
framework = FrameworkData(
377+
name=framework_name.lower(),
378+
)
386379
project_metadata = ProjectMetadata(
387380
project_name=project_details["name"],
388381
description=project_details["description"],
@@ -422,7 +415,7 @@ def insert_template(
422415
"red",
423416
)
424417
)
425-
return
418+
sys.exit(1)
426419

427420
cookiecutter(str(template_path), no_input=True, extra_context=None)
428421

@@ -445,10 +438,13 @@ def insert_template(
445438
"🚀 \033[92mAgentStack project generated successfully!\033[0m\n\n"
446439
" Next, run:\n"
447440
f" cd {project_metadata.project_slug}\n"
448-
" poetry install\n"
449-
" agentstack run\n\n"
441+
" python -m venv .venv\n"
442+
" source .venv/bin/activate\n"
443+
" poetry install\n\n"
450444
" Add agents and tasks with:\n"
451445
" `agentstack generate agent/task <name>`\n\n"
446+
" Run your agent with:\n"
447+
" agentstack run\n\n"
452448
" Run `agentstack quickstart` or `agentstack docs` for next steps.\n"
453449
)
454450

agentstack/generation/files.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from pathlib import Path
55
from pydantic import BaseModel
6+
from agentstack.utils import get_version
67

78

89
DEFAULT_FRAMEWORK = "crewai"
@@ -34,12 +35,21 @@ class ConfigFile(BaseModel):
3435
Whether the user has opted out of telemetry.
3536
default_model: Optional[str]
3637
The default model to use when generating agent configurations.
38+
agentstack_version: Optional[str]
39+
The version of agentstack used to generate the project.
40+
template: Optional[str]
41+
The template used to generate the project.
42+
template_version: Optional[str]
43+
The version of the template system used to generate the project.
3744
"""
3845

3946
framework: str = DEFAULT_FRAMEWORK
4047
tools: list[str] = []
4148
telemetry_opt_out: Optional[bool] = None
4249
default_model: Optional[str] = None
50+
agentstack_version: Optional[str] = get_version()
51+
template: Optional[str] = None
52+
template_version: Optional[str] = None
4353

4454
def __init__(self, path: Union[str, Path, None] = None):
4555
path = Path(path) if path else Path.cwd()

agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ version = "{{cookiecutter.project_metadata.version}}"
44
description = "{{cookiecutter.project_metadata.description}}"
55
authors = ["{{cookiecutter.project_metadata.author_name}}"]
66
license = "{{cookiecutter.project_metadata.license}}"
7+
package-mode = false
78

89
[tool.poetry.dependencies]
910
python = ">=3.10,<=3.13"
11+
agentstack = {extras = ["{{cookiecutter.framework}}"], version="{{cookiecutter.project_metadata.agentstack_version}}"}
1012

1113
[project.scripts]
1214
{{cookiecutter.project_metadata.project_name}} = "{{cookiecutter.project_metadata.project_name}}.main:run"

agentstack/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def get_telemetry_opt_out(path: Optional[str] = None) -> bool:
5858
Gets the telemetry opt out setting.
5959
First checks the environment variable AGENTSTACK_TELEMETRY_OPT_OUT.
6060
If that is not set, it checks the agentstack.json file.
61+
Otherwise we can assume the user has not opted out.
6162
"""
6263
from agentstack.generation import ConfigFile
6364

@@ -67,8 +68,7 @@ def get_telemetry_opt_out(path: Optional[str] = None) -> bool:
6768
agentstack_config = ConfigFile(path)
6869
return bool(agentstack_config.telemetry_opt_out)
6970
except FileNotFoundError:
70-
print("\033[31mFile agentstack.json does not exist. Are you in the right directory?\033[0m")
71-
sys.exit(1)
71+
return False
7272

7373

7474
def camel_to_snake(name):

tests/test_generation_files.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
verify_agentstack_project,
88
get_framework,
99
get_telemetry_opt_out,
10+
get_version,
1011
)
1112

1213
BASE_PATH = Path(__file__).parent
@@ -19,6 +20,9 @@ def test_read_config(self):
1920
assert config.tools == []
2021
assert config.telemetry_opt_out is None
2122
assert config.default_model is None
23+
assert config.agentstack_version == get_version()
24+
assert config.template is None
25+
assert config.template_version is None
2226

2327
def test_write_config(self):
2428
try:
@@ -30,6 +34,9 @@ def test_write_config(self):
3034
config.tools = ["tool1", "tool2"]
3135
config.telemetry_opt_out = True
3236
config.default_model = "openai/gpt-4o"
37+
config.agentstack_version = "0.2.1"
38+
config.template = "default"
39+
config.template_version = "1"
3340

3441
tmp_data = open(BASE_PATH / "tmp/agentstack.json").read()
3542
assert (
@@ -41,7 +48,10 @@ def test_write_config(self):
4148
"tool2"
4249
],
4350
"telemetry_opt_out": true,
44-
"default_model": "openai/gpt-4o"
51+
"default_model": "openai/gpt-4o",
52+
"agentstack_version": "0.2.1",
53+
"template": "default",
54+
"template_version": "1"
4555
}"""
4656
)
4757
except Exception as e:

0 commit comments

Comments
 (0)