From 5bf538924e2dee413b1d240ca74e7233bd726124 Mon Sep 17 00:00:00 2001 From: Dhanush Reddy <76517652+dhanushreddy291@users.noreply.github.com> Date: Sun, 2 Feb 2025 12:01:59 +0530 Subject: [PATCH 1/2] fix empty template initialization --- agentstack/cli/init.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/agentstack/cli/init.py b/agentstack/cli/init.py index b471c716..b76541ad 100644 --- a/agentstack/cli/init.py +++ b/agentstack/cli/init.py @@ -45,7 +45,10 @@ def select_template(slug_name: str, framework: Optional[str] = None) -> Template message="Do you want to start with a template?", choices=[empty_msg] + template_names, ) - template_name = template_choice.split("⚡️ ")[1].split(" - ")[0] + if '⚡️' not in template_choice: + template_name = empty_msg + else: + template_name = template_choice.split("⚡️ ")[1].split(" - ")[0] if template_name == empty_msg: return TemplateConfig( From 1f3023cc7c707ba9dce8574bba303cefc869bfa0 Mon Sep 17 00:00:00 2001 From: Travis Dent Date: Mon, 3 Feb 2025 09:37:31 -0800 Subject: [PATCH 2/2] Better matching for template selection on init --- agentstack/cli/init.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/agentstack/cli/init.py b/agentstack/cli/init.py index b76541ad..8c8bce45 100644 --- a/agentstack/cli/init.py +++ b/agentstack/cli/init.py @@ -38,19 +38,21 @@ def require_uv(): def select_template(slug_name: str, framework: Optional[str] = None) -> TemplateConfig: """Let the user select a template from the ones available.""" templates: list[TemplateConfig] = get_all_templates() - template_names = [shorten(f"⚡️ {t.name} - {t.description}", 80) for t in templates] - empty_msg = "🆕 Empty Project" - template_choice = inquirer.list_input( + EMPTY = 'empty' + choices = [ + (EMPTY, "🆕 Empty Project"), + ] + for template in templates: + choices.append((template.name, shorten(f"⚡️ {template.name} - {template.description}", 80))) + + choice = inquirer.list_input( message="Do you want to start with a template?", - choices=[empty_msg] + template_names, + choices=[c[1] for c in choices], ) - if '⚡️' not in template_choice: - template_name = empty_msg - else: - template_name = template_choice.split("⚡️ ")[1].split(" - ")[0] + template_name = next(c[0] for c in choices if c[1] == choice) - if template_name == empty_msg: + if template_name == EMPTY: return TemplateConfig( name=slug_name, description="",