|
1 | | -# How to Contribute |
| 1 | +# Contributing to Agent Starter Pack |
2 | 2 |
|
3 | | -We'd love to accept your patches and contributions to this sample. There are |
4 | | -just a few small guidelines you need to follow. |
| 3 | +We welcome contributions to the Agent Starter Pack! This guide helps you understand the project and make effective contributions. |
5 | 4 |
|
6 | | -## Contributor License Agreement |
| 5 | +## Quick Navigation |
7 | 6 |
|
8 | | -Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to [Google Developers CLA](https://cla.developers.google.com/) to see your current agreements on file or to sign a new one. |
| 7 | +| What you're changing | Start here | |
| 8 | +|---------------------|------------| |
| 9 | +| Template files (Jinja templates in base_templates/) | [Template Development Workflow](#template-development-workflow) | |
| 10 | +| CLI commands (cli/commands/) | [Code Quality](#code-quality) | |
| 11 | +| Documentation | [Pull Request Process](#pull-request-process) | |
| 12 | +| **AI coding agents** | See [GEMINI.md](./GEMINI.md) for comprehensive AI agent guidance | |
9 | 13 |
|
10 | | -You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. |
| 14 | +## Understanding ASP Architecture |
11 | 15 |
|
12 | | -## Code Reviews |
| 16 | +Agent Starter Pack is a **template generator**, not a runtime framework. The CLI generates standalone projects that users then customize and deploy. |
13 | 17 |
|
14 | | -All submissions, including submissions by project members, require review. We |
15 | | -use GitHub pull requests for this purpose. Consult |
16 | | -[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more |
17 | | -information on using pull requests. |
| 18 | +### 4-Layer Template System |
18 | 19 |
|
19 | | -## Community Guidelines |
| 20 | +Templates are processed in order, with later layers overriding earlier ones: |
20 | 21 |
|
21 | | -This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). |
| 22 | +1. **Base Templates** (`agent_starter_pack/base_templates/<language>/`) - Core Jinja scaffolding (Python, Go, more coming) |
| 23 | +2. **Deployment Targets** (`agent_starter_pack/deployment_targets/`) - Environment-specific overrides (cloud_run, agent_engine) |
| 24 | +3. **Frontend Types** (`agent_starter_pack/frontends/`) - UI-specific files |
| 25 | +4. **Agent Templates** (`agent_starter_pack/agents/*/`) - Agent-specific logic and configurations |
22 | 26 |
|
23 | | -## Contributor Guide |
| 27 | +### Key Directories |
24 | 28 |
|
25 | | -If you are new to contributing to open source, you can find helpful information in this contributor guide. |
| 29 | +| Directory | Purpose | |
| 30 | +|-----------|---------| |
| 31 | +| `agent_starter_pack/base_templates/` | Jinja templates by language (see [Language-Specific Notes](#language-specific-notes)) | |
| 32 | +| `agent_starter_pack/deployment_targets/` | Files that override/extend base for specific deployments | |
| 33 | +| `agent_starter_pack/agents/` | Agent-specific files (adk, adk_live, langgraph, etc.) | |
| 34 | +| `agent_starter_pack/cli/commands/` | CLI command implementations (create, setup-cicd, etc.) | |
| 35 | +| `agent_starter_pack/cli/utils/` | Shared utilities including template processing | |
26 | 36 |
|
27 | | -You may follow these steps to contribute: |
| 37 | +## Template Development Workflow |
28 | 38 |
|
29 | | -1. **Fork the official repository.** This will create a copy of the official repository in your own account. |
30 | | -2. **Sync the branches.** This will ensure that your copy of the repository is up-to-date with the latest changes from the official repository. |
31 | | -3. **Work on your forked repository's feature branch.** This is where you will make your changes to the code. |
32 | | -4. **Commit your updates on your forked repository's feature branch.** This will save your changes to your copy of the repository. |
33 | | -5. **Submit a pull request to the official repository's main branch.** This will request that your changes be merged into the official repository. |
34 | | -6. **Resolve any linting errors.** This will ensure that your changes are formatted correctly. |
35 | | - - For errors generated by [check-spelling](https://github.com/check-spelling/check-spelling), go to the [Job Summary](https://github.com/GoogleCloudPlatform/generative-ai/actions/workflows/spelling.yaml) to read the errors. |
36 | | - - Fix any spelling errors that are found. |
37 | | - - Forbidden Patterns are defined as regular expressions, you can copy/paste them into many IDEs to find the instances. [Example for Visual Studio Code](https://medium.com/@nikhilbaxi3/visual-studio-code-secrets-of-regular-expression-search-71723c2ecbd2). |
38 | | - - Add false positives to [`.github/actions/spelling/allow.txt`](.github/actions/spelling/allow.txt). Be sure to check that it's actually spelled correctly! |
| 39 | +Template changes require a specific workflow because you're modifying Jinja templates. |
39 | 40 |
|
40 | | -Here are some additional things to keep in mind during the process: |
| 41 | +### Recommended Process |
41 | 42 |
|
42 | | -- **Read the [Google's Open Source Community Guidelines](https://opensource.google/conduct/).** The contribution guidelines will provide you with more information about the project and how to contribute. |
43 | | -- **Test your changes.** Before you submit a pull request, make sure that your changes work as expected. |
44 | | -- **Be patient.** It may take some time for your pull request to be reviewed and merged. |
| 43 | +1. **Generate a test instance** |
| 44 | + ```bash |
| 45 | + uv run agent-starter-pack create mytest -p -s -y -d cloud_run --output-dir target |
| 46 | + ``` |
| 47 | + Flags: `-p` prototype (no CI/CD), `-s` skip checks, `-y` auto-approve |
45 | 48 |
|
46 | | ---- |
| 49 | +2. **Initialize git in the generated project** |
| 50 | + ```bash |
| 51 | + cd target/mytest && git init && git add . && git commit -m "Initial" |
| 52 | + ``` |
47 | 53 |
|
48 | | -## For Google Employees |
| 54 | +3. **Develop with tight feedback loops** |
| 55 | + - Make changes directly in `target/mytest/` |
| 56 | + - Test immediately with `make lint` and running the code |
| 57 | + - Iterate until the change works |
| 58 | + |
| 59 | +4. **Backport changes to Jinja templates** |
| 60 | + - Identify the source template file in `agent_starter_pack/` |
| 61 | + - Apply your changes, adding Jinja conditionals if needed |
| 62 | + - Use `{%- -%}` whitespace control carefully (see [GEMINI.md](./GEMINI.md#critical-whitespace-control-patterns)) |
| 63 | + |
| 64 | +5. **Validate across combinations** |
| 65 | + ```bash |
| 66 | + # Test your target combination |
| 67 | + _TEST_AGENT_COMBINATION="adk,cloud_run,--session-type,in_memory" make lint-templated-agents |
| 68 | + |
| 69 | + # Test alternate agent with same deployment |
| 70 | + _TEST_AGENT_COMBINATION="adk_live,cloud_run" make lint-templated-agents |
49 | 71 |
|
50 | | -If you're a Google employee, as a requirement, please follow the steps outlined in the [Google Cloud Platform Generative AI repository's contributing guide](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/CONTRIBUTING.md#for-google-employees) for processes and requirements. |
| 72 | + # Test same agent with alternate deployment |
| 73 | + _TEST_AGENT_COMBINATION="adk,agent_engine" make lint-templated-agents |
| 74 | + ``` |
51 | 75 |
|
52 | | -## Code Quality Checks |
| 76 | +### Why This Workflow? |
53 | 77 |
|
54 | | -To ensure code quality, we utilize automated checks. Before submitting a pull request, please run the following commands locally: |
| 78 | +- Jinja templates are harder to debug than rendered code |
| 79 | +- Generated projects give immediate feedback on syntax errors |
| 80 | +- Backporting ensures you understand exactly what changed |
| 81 | +- Cross-combination testing catches conditional logic bugs |
55 | 82 |
|
| 83 | +### Language-Specific Notes |
| 84 | + |
| 85 | +The template development workflow above applies to all languages. Here are language-specific details: |
| 86 | + |
| 87 | +| Language | Agent(s) | Linter | Test Command | Status | |
| 88 | +|----------|----------|--------|--------------|--------| |
| 89 | +| Python | adk, adk_a2a, adk_live, agentic_rag, langgraph, custom_a2a | `ruff`, `ty` | `make lint` | Production | |
| 90 | +| Go | adk_go | `golangci-lint` | `make lint` | Production | |
| 91 | +| Java | (coming soon) | - | - | In development | |
| 92 | +| TypeScript | (coming soon) | - | - | In development | |
| 93 | + |
| 94 | +**Python example:** |
56 | 95 | ```bash |
57 | | -make install |
| 96 | +uv run agent-starter-pack create mytest -a adk -d cloud_run -p -s -y --output-dir target |
58 | 97 | ``` |
59 | 98 |
|
60 | | -This installs development dependencies, including linting tools. |
| 99 | +**Go example:** |
| 100 | +```bash |
| 101 | +uv run agent-starter-pack create mytest -a adk_go -d cloud_run -p -s -y --output-dir target |
| 102 | +``` |
61 | 103 |
|
62 | | -Then, execute the following Make command: |
| 104 | +## Testing Your Changes |
| 105 | + |
| 106 | +### Local Testing |
63 | 107 |
|
64 | 108 | ```bash |
| 109 | +# Install dependencies (first time) |
| 110 | +make install |
| 111 | + |
| 112 | +# Run linters (ruff, ty, codespell) |
65 | 113 | make lint |
| 114 | + |
| 115 | +# Run test suite |
| 116 | +make test |
66 | 117 | ``` |
67 | 118 |
|
68 | | -This command runs the following linters to check for code style, potential errors, and type hints: |
| 119 | +### Template Combination Testing |
69 | 120 |
|
70 | | -- **codespell**: Detects common spelling mistakes in code and documentation. |
71 | | -- **ruff**: A fast Python linter and formatter, it checks for errors, coding standards, and enforces style consistency. |
72 | | -- **ty**: Performs static type checking to catch type errors before runtime (Astral's Rust-based type checker). |
| 121 | +Template changes can affect multiple agent/deployment combinations. Test the minimum coverage matrix: |
73 | 122 |
|
74 | 123 | ```bash |
75 | | -make test |
| 124 | +# Format: agent,deployment_target,--flag,value |
| 125 | +_TEST_AGENT_COMBINATION="adk,cloud_run,--session-type,in_memory" make lint-templated-agents |
| 126 | +_TEST_AGENT_COMBINATION="adk,agent_engine" make lint-templated-agents |
| 127 | +_TEST_AGENT_COMBINATION="langgraph,cloud_run" make lint-templated-agents |
| 128 | +``` |
| 129 | + |
| 130 | +**Minimum coverage before PR:** |
| 131 | +- [ ] Your target combination |
| 132 | +- [ ] One alternate agent with same deployment target |
| 133 | +- [ ] One alternate deployment target with same agent |
| 134 | + |
| 135 | +### Quick Project Generation for Testing |
| 136 | + |
| 137 | +```bash |
| 138 | +# Fastest: Agent Engine prototype |
| 139 | +uv run agent-starter-pack create test-$(date +%s) -p -s -y -d agent_engine --output-dir target |
| 140 | + |
| 141 | +# Cloud Run with session type |
| 142 | +uv run agent-starter-pack create test-$(date +%s) -p -s -y -d cloud_run --session-type in_memory --output-dir target |
| 143 | + |
| 144 | +# Full project with CI/CD |
| 145 | +uv run agent-starter-pack create test-$(date +%s) -s -y -d agent_engine --cicd-runner google_cloud_build --output-dir target |
| 146 | +``` |
| 147 | + |
| 148 | +## Pull Request Process |
| 149 | + |
| 150 | +### Commit Message Format |
| 151 | + |
76 | 152 | ``` |
| 153 | +<type>: <concise summary in imperative mood> |
| 154 | +
|
| 155 | +<detailed explanation if needed> |
| 156 | +- Why the change was needed |
| 157 | +- What was the root cause (for fixes) |
| 158 | +- How the fix addresses it |
| 159 | +``` |
| 160 | + |
| 161 | +**Types**: `fix`, `feat`, `refactor`, `docs`, `test`, `chore` |
| 162 | + |
| 163 | +### PR Description Template |
| 164 | + |
| 165 | +```markdown |
| 166 | +## Summary |
| 167 | +- Key change 1 |
| 168 | +- Key change 2 |
| 169 | + |
| 170 | +## Problem (for fixes) |
| 171 | +Description of the issue, including error messages if applicable. |
| 172 | + |
| 173 | +## Solution |
| 174 | +How the changes fix the problem. |
| 175 | + |
| 176 | +## Testing |
| 177 | +- [ ] Tested combination: agent,deployment |
| 178 | +- [ ] Tested alternate: agent2,deployment |
| 179 | +- [ ] Tested alternate: agent,deployment2 |
| 180 | +``` |
| 181 | + |
| 182 | +### Required Checks |
| 183 | + |
| 184 | +All PRs must pass: |
| 185 | +- `make lint` - Code style and type checking |
| 186 | +- `make test` - Unit and integration tests |
| 187 | +- Template linting for affected combinations |
| 188 | + |
| 189 | +## Code Quality |
| 190 | + |
| 191 | +### Linting Tools |
| 192 | + |
| 193 | +| Tool | Purpose | |
| 194 | +|------|---------| |
| 195 | +| `ruff` | Python linting and formatting | |
| 196 | +| `ty` | Static type checking (Astral's Rust-based checker) | |
| 197 | +| `codespell` | Spelling mistakes in code and docs | |
| 198 | + |
| 199 | +### Template-Specific Linting |
| 200 | + |
| 201 | +For template files, also ensure: |
| 202 | +- All Jinja blocks are balanced (`{% if %}` has `{% endif %}`) |
| 203 | +- Whitespace control is correct (see [GEMINI.md](./GEMINI.md#critical-whitespace-control-patterns)) |
| 204 | +- Generated files pass `ruff` in all combinations |
| 205 | + |
| 206 | +### Spelling Errors |
| 207 | + |
| 208 | +For errors from [check-spelling](https://github.com/check-spelling/check-spelling): |
| 209 | +1. Check the Job Summary for specific errors |
| 210 | +2. Fix actual spelling mistakes |
| 211 | +3. Add false positives to `.github/actions/spelling/allow.txt` |
| 212 | + |
| 213 | +## Contributor License Agreement |
| 214 | + |
| 215 | +Contributions must be accompanied by a Contributor License Agreement. You (or your employer) retain copyright; this gives us permission to use and redistribute your contributions. |
| 216 | + |
| 217 | +Sign at [Google Developers CLA](https://cla.developers.google.com/). You generally only need to submit once. |
| 218 | + |
| 219 | +## Community Guidelines |
| 220 | + |
| 221 | +This project follows [Google's Open Source Community Guidelines](https://opensource.google/conduct/). |
| 222 | + |
| 223 | +## For Google Employees |
| 224 | + |
| 225 | +Follow the additional steps in the [Generative AI on Google Cloud repository's contributing guide](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/CONTRIBUTING.md#for-google-employees). |
| 226 | + |
| 227 | +--- |
77 | 228 |
|
78 | | -This command runs the test suite using pytest, covering both unit and integration tests: |
| 229 | +## Additional Resources |
79 | 230 |
|
80 | | -Your pull request will also be automatically checked by these tools using GitHub Actions. Ensuring your code passes these checks locally will help expedite the review process. |
| 231 | +- **[GEMINI.md](./GEMINI.md)** - Comprehensive guide for AI coding agents, including Jinja patterns and debugging |
| 232 | +- **[docs/](./docs/)** - User-facing documentation for generated projects |
0 commit comments