-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add go support to upgrade command and update docs #730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| # extract | ||
|
|
||
| The `extract` command creates a minimal, shareable version of your agent by stripping away deployment infrastructure while preserving your core agent logic. This is useful for sharing agents, creating starter templates, or distributing agent code without the full project scaffolding. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| uvx agent-starter-pack extract OUTPUT_PATH [OPTIONS] | ||
| ``` | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `OUTPUT_PATH` (required): Path where the extracted agent will be created | ||
|
|
||
| ## Options | ||
|
|
||
| | Option | Default | Description | | ||
| |--------|---------|-------------| | ||
| | `--source, -s` | `.` (current directory) | Source project directory | | ||
| | `--dry-run` | `false` | Show what would be extracted without making changes | | ||
| | `--force, -f` | `false` | Overwrite output directory if it exists | | ||
| | `--debug` | `false` | Enable debug logging | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Basic Extraction | ||
|
|
||
| ```bash | ||
| # Extract current project to a new directory | ||
| uvx agent-starter-pack extract ../my-agent-share | ||
|
|
||
| # Extract from a specific source directory | ||
| uvx agent-starter-pack extract ./shared-agent --source /path/to/project | ||
| ``` | ||
|
|
||
| ### Preview Changes | ||
|
|
||
| ```bash | ||
| # See what would be extracted without making changes | ||
| uvx agent-starter-pack extract ../my-agent-share --dry-run | ||
| ``` | ||
|
|
||
| ### Overwrite Existing | ||
|
|
||
| ```bash | ||
| # Force overwrite if output directory exists | ||
| uvx agent-starter-pack extract ../my-agent-share --force | ||
| ``` | ||
|
|
||
| ## What Gets Extracted | ||
|
|
||
| The extract command preserves your core agent code while removing deployment scaffolding: | ||
|
|
||
| **Kept (Agent Code):** | ||
| - Agent directory (e.g., `app/`) with your `agent.py` and custom modules | ||
| - `pyproject.toml` (with scaffolding dependencies removed) | ||
|
allen-stephen marked this conversation as resolved.
|
||
| - `.gitignore` | ||
| - `GEMINI.md` (if present) | ||
|
|
||
| **Removed (Scaffolding):** | ||
| - `deployment/` - Terraform infrastructure | ||
| - `.github/` or `.cloudbuild/` - CI/CD pipelines | ||
| - `frontend/` - UI components | ||
| - `data_ingestion/` - Data pipeline code | ||
| - `notebooks/` - Jupyter notebooks | ||
| - `tests/` - Test files | ||
| - `tools/` - Build tools | ||
| - Scaffolding files in agent directory (`fast_api_app.py`, `agent_engine_app.py`, `app_utils/`) | ||
|
|
||
| **Generated:** | ||
| - Minimal `Makefile` with basic commands (`install`, `playground`, `lint`) | ||
| - Simplified `README.md` for the extracted project | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Detects project language** (Python or Go) from project files | ||
| 2. **Reads ASP metadata** from `pyproject.toml` or `.asp.toml` | ||
| 3. **Copies agent code** excluding scaffolding files | ||
| 4. **Strips scaffolding dependencies** from `pyproject.toml` | ||
|
allen-stephen marked this conversation as resolved.
|
||
| 5. **Generates minimal Makefile and README** for standalone use | ||
| 6. **Regenerates lock file** (`uv lock` or `go mod tidy`) | ||
|
|
||
| ## Relationship to `enhance` | ||
|
|
||
| The `extract` and `enhance` commands are complementary: | ||
|
|
||
| ``` | ||
| Full Project ──extract──> Minimal Agent ──enhance──> Full Project | ||
| ``` | ||
|
|
||
| - **extract**: Remove scaffolding to create a shareable, minimal agent | ||
| - **enhance**: Add scaffolding back to restore production capabilities | ||
|
|
||
| This workflow enables: | ||
| 1. **Sharing**: Extract your agent, share it with others | ||
| 2. **Receiving**: Others run `enhance` to add their own deployment infrastructure | ||
| 3. **Customization**: Recipients can choose different deployment targets, CI/CD runners, etc. | ||
|
|
||
| ## Example Workflow | ||
|
|
||
| ```bash | ||
| # 1. Create a full project | ||
| uvx agent-starter-pack create my-agent -a adk -d cloud_run | ||
|
|
||
| # 2. Develop your agent... | ||
| cd my-agent | ||
| # ... edit app/agent.py ... | ||
|
|
||
| # 3. Extract for sharing | ||
| uvx agent-starter-pack extract ../my-agent-share | ||
|
|
||
| # 4. Share the extracted agent (e.g., push to GitHub) | ||
| cd ../my-agent-share | ||
| git init && git add . && git commit -m "Initial agent" | ||
|
|
||
| # 5. Recipients can enhance with their own preferences | ||
| uvx agent-starter-pack enhance --deployment-target agent_engine | ||
| ``` | ||
|
|
||
| ## Language Support | ||
|
|
||
| The extract command supports both Python and Go projects: | ||
|
|
||
| | Language | Config File | Lock Command | | ||
| |----------|-------------|--------------| | ||
| | Python | `pyproject.toml` | `uv lock` | | ||
| | Go | `.asp.toml` | `go mod tidy` | | ||
|
|
||
| Language is auto-detected from project files. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| # upgrade | ||
|
|
||
| The `upgrade` command updates your project to the latest version of agent-starter-pack using an intelligent 3-way merge. It automatically applies updates to scaffolding files while preserving your customizations. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| uvx agent-starter-pack upgrade [PROJECT_PATH] [OPTIONS] | ||
| ``` | ||
|
|
||
| ## Arguments | ||
|
|
||
| - `PROJECT_PATH` (optional): Path to the project to upgrade (default: current directory) | ||
|
|
||
| ## Options | ||
|
|
||
| | Option | Default | Description | | ||
| |--------|---------|-------------| | ||
| | `--dry-run` | `false` | Preview changes without applying them | | ||
| | `--auto-approve, -y` | `false` | Auto-apply non-conflicting changes without prompts | | ||
| | `--debug` | `false` | Enable debug logging | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Basic Upgrade | ||
|
|
||
| ```bash | ||
| # Upgrade current project | ||
| uvx agent-starter-pack upgrade | ||
|
|
||
| # Upgrade a specific project | ||
| uvx agent-starter-pack upgrade /path/to/project | ||
| ``` | ||
|
|
||
| ### Preview Changes | ||
|
|
||
| ```bash | ||
| # See what would change without applying | ||
| uvx agent-starter-pack upgrade --dry-run | ||
| ``` | ||
|
|
||
| ### Non-Interactive Upgrade | ||
|
|
||
| ```bash | ||
| # Auto-approve all non-conflicting changes | ||
| uvx agent-starter-pack upgrade -y | ||
| ``` | ||
|
|
||
| ## How the 3-Way Merge Works | ||
|
|
||
| The upgrade command uses a 3-way comparison between: | ||
| 1. **Your current project** - The files as they exist now | ||
| 2. **Old ASP template** - What ASP generated at your project's version | ||
| 3. **New ASP template** - What ASP generates at the latest version | ||
|
|
||
| This enables intelligent decision-making: | ||
|
|
||
| | Your Changes | ASP Changes | Result | | ||
| |--------------|-------------|--------| | ||
| | None | Updated | **Auto-update** - Apply ASP's changes | | ||
| | Modified | None | **Preserve** - Keep your changes | | ||
| | Modified | Updated | **Conflict** - Prompt for resolution | | ||
| | N/A | New file | **Add** - Prompt to add new file | | ||
| | N/A | Removed | **Remove** - Prompt to remove file | | ||
|
|
||
| ### Files Always Preserved | ||
|
|
||
| The following are never modified by upgrade: | ||
| - **Agent code** (e.g., `app/agent.py`, custom modules) | ||
| - **Configuration files** (`.env`, secrets, local configs) | ||
|
|
||
| ### Conflict Resolution | ||
|
|
||
| When both you and ASP have modified a file, you'll be prompted: | ||
| - **(v)iew diff** - See the differences between versions | ||
| - **(k)eep yours** - Preserve your current version | ||
| - **(u)se new** - Replace with ASP's new version | ||
| - **(s)kip** - Don't change the file | ||
|
|
||
| ## Dependency Handling | ||
|
|
||
| The upgrade command intelligently merges dependencies in `pyproject.toml`: | ||
|
|
||
| - **ASP dependencies updated** → Automatically update version | ||
| - **Your custom dependencies** → Preserved unchanged | ||
| - **New ASP dependencies** → Added to your project | ||
| - **Removed ASP dependencies** → Optionally removed | ||
|
|
||
| Version constraints are respected, and your custom additions are never removed. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - **uvx**: Required for re-generating templates at specific versions | ||
| - **Project metadata**: Your `pyproject.toml` must have `[tool.agent-starter-pack]` with `asp_version` | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **Reads project metadata** to determine current ASP version | ||
| 2. **Re-generates old template** using `uvx agent-starter-pack@{old_version}` | ||
| 3. **Re-generates new template** using current ASP version | ||
| 4. **Compares all files** using 3-way diff | ||
| 5. **Applies changes** based on comparison results | ||
| 6. **Updates metadata** to reflect new version | ||
|
|
||
| ## Example Workflow | ||
|
|
||
| ```bash | ||
| # Check current version in pyproject.toml | ||
| grep asp_version pyproject.toml | ||
| # asp_version = "0.30.0" | ||
|
|
||
| # Preview what would change | ||
| uvx agent-starter-pack upgrade --dry-run | ||
|
|
||
| # Output shows: | ||
| # Auto-updating (unchanged by you): | ||
| # ✓ deployment/terraform/main.tf | ||
| # ✓ .github/workflows/ci.yaml | ||
| # | ||
| # Preserving (you modified, ASP unchanged): | ||
| # ✓ Makefile | ||
| # | ||
| # Conflicts (both changed): | ||
| # ⚠ deployment/terraform/variables.tf | ||
|
|
||
| # Apply the upgrade | ||
| uvx agent-starter-pack upgrade | ||
|
|
||
| # Resolve any conflicts interactively | ||
| # ... | ||
|
|
||
| # Verify upgrade | ||
| grep asp_version pyproject.toml | ||
| # asp_version = "0.31.0" | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Commit before upgrading** - Ensure you can easily revert if needed | ||
| 2. **Use dry-run first** - Preview changes before applying | ||
| 3. **Review conflicts carefully** - Don't blindly accept new versions | ||
| 4. **Test after upgrade** - Run `make test` to verify everything works | ||
| 5. **Check dependency changes** - Review any updated package versions | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **"No agent-starter-pack metadata found"** | ||
| - Ensure `pyproject.toml` has `[tool.agent-starter-pack]` section | ||
| - This project may not have been created with agent-starter-pack | ||
|
|
||
| **"No asp_version found"** | ||
| - Add `asp_version = "X.Y.Z"` to `[tool.agent-starter-pack]` in `pyproject.toml` | ||
| - Use the version you originally created the project with | ||
|
|
||
| **"Failed to generate old template"** | ||
| - The old version may not be available on PyPI | ||
| - Try upgrading from a more recent version | ||
|
|
||
| **"uvx is required but not installed"** | ||
| - Install uv: `curl -LsSf https://astral.sh/uv/install.sh | sh` | ||
|
allen-stephen marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.