Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
596 changes: 596 additions & 0 deletions agent_starter_pack/cli/commands/upgrade.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions agent_starter_pack/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .commands.list import list_agents
from .commands.register_gemini_enterprise import register_gemini_enterprise
from .commands.setup_cicd import setup_cicd
from .commands.upgrade import upgrade
from .utils import display_update_message

console = Console()
Expand Down Expand Up @@ -62,6 +63,7 @@ def cli() -> None:
cli.add_command(extract)
cli.add_command(register_gemini_enterprise)
cli.add_command(setup_cicd)
cli.add_command(upgrade)
cli.add_command(list_agents, name="list")


Expand Down
2 changes: 2 additions & 0 deletions agent_starter_pack/cli/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from .datastores import DATASTORE_TYPES, get_datastore_info
from .gcp import verify_credentials_and_vertex
from .generation_metadata import metadata_to_cli_args
from .logging import handle_cli_error
from .template import (
get_available_agents,
Expand All @@ -35,6 +36,7 @@
"get_template_path",
"handle_cli_error",
"load_template_config",
"metadata_to_cli_args",
"process_template",
"prompt_datastore_selection",
"prompt_deployment_target",
Expand Down
50 changes: 50 additions & 0 deletions agent_starter_pack/cli/utils/generation_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Utilities for converting project metadata to CLI arguments."""

from typing import Any


def metadata_to_cli_args(metadata: dict[str, Any]) -> list[str]:
"""Convert metadata to CLI arguments for re-creating a project.

Maps [tool.agent-starter-pack] metadata back to CLI arguments.
Used by upgrade command to re-template old/new versions.
"""
args: list[str] = []

if "base_template" in metadata:
args.extend(["--agent", metadata["base_template"]])

if "agent_directory" in metadata and metadata["agent_directory"] != "app":
args.extend(["--agent-directory", metadata["agent_directory"]])

create_params = metadata.get("create_params", {})
for key, value in create_params.items():
if (
value is None
or value is False
or str(value).lower() == "none"
or value == ""
):
continue

arg_name = f"--{key.replace('_', '-')}"
if value is True:
args.append(arg_name)
else:
args.extend([arg_name, str(value)])

return args
Loading