|
| 1 | +# Dynamic Adapter AI Tools |
| 2 | + |
| 3 | +This directory contains tools for generating prompts and tickets for dynamic adapter development and testing. |
| 4 | + |
| 5 | +## Files |
| 6 | + |
| 7 | +- `generate-test-ticket-cmd/` - Go implementation for generating Linear ticket content for dynamic adapter unit tests |
| 8 | +- `generate-adapter-ticket-cmd/` - Go implementation for generating Linear ticket content for creating new dynamic adapters |
| 9 | +- `build.sh` - Build script for both tools |
| 10 | +- `README.md` - This documentation |
| 11 | + |
| 12 | +## Related Files |
| 13 | + |
| 14 | +- `../adapters/.cursor/rules/dynamic-adapter-testing.md` - Cursor agent rules for writing adapter tests |
| 15 | +- `../adapters/.cursor/rules/dynamic-adapter-creation.md` - Cursor agent rules for creating new adapters |
| 16 | +- `../adapters/` - Directory containing dynamic adapter implementations |
| 17 | + |
| 18 | +## generate-adapter-ticket |
| 19 | + |
| 20 | +### Purpose |
| 21 | +Generates complete Linear ticket content for creating new dynamic adapters. This tool helps create comprehensive tickets for implementing new GCP resource adapters with proper context and requirements. |
| 22 | + |
| 23 | +### Usage |
| 24 | +```bash |
| 25 | +# Run directly with go run |
| 26 | +go run generate-adapter-ticket-cmd/main.go -name <adapter-name> -api-ref <api-reference-url> [-type-ref <type-reference-url>] [--verbose] |
| 27 | + |
| 28 | +# Or build and run |
| 29 | +./build.sh |
| 30 | +./generate-adapter-ticket -name <adapter-name> -api-ref <api-reference-url> [-type-ref <type-reference-url>] [--verbose] |
| 31 | + |
| 32 | +# Build for specific platform |
| 33 | +./build.sh linux/amd64 |
| 34 | +./build.sh darwin/arm64 |
| 35 | +``` |
| 36 | + |
| 37 | +### Examples |
| 38 | +```bash |
| 39 | +# Generate ticket for monitoring alert policy adapter |
| 40 | +go run generate-adapter-ticket-cmd/main.go -name monitoring-alert-policy -api-ref "https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies" |
| 41 | + |
| 42 | +# Generate ticket with type reference |
| 43 | +go run generate-adapter-ticket-cmd/main.go -name compute-instance-template -api-ref "https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates" -type-ref "https://cloud.google.com/compute/docs/reference/rest/v1/instanceTemplates#InstanceTemplate" |
| 44 | + |
| 45 | +# Generate with verbose output |
| 46 | +go run generate-adapter-ticket-cmd/main.go --verbose -name storage-bucket -api-ref "https://cloud.google.com/storage/docs/json_api/v1/buckets" |
| 47 | +``` |
| 48 | + |
| 49 | +### What it does |
| 50 | +1. **Create Linear ticket** for new adapter implementation |
| 51 | +2. **Generate comprehensive context** with API references |
| 52 | +3. **Include implementation checklist** following dynamic adapter patterns |
| 53 | +4. **Reference Cursor rules** for consistent implementation |
| 54 | +5. **Copy description to clipboard** and optionally print it |
| 55 | + |
| 56 | +### Output |
| 57 | +The tool generates a Linear URL with pre-filled fields and copies the description to clipboard. The description includes: |
| 58 | +- Task overview |
| 59 | +- API references |
| 60 | +- Files to create |
| 61 | +- Implementation instructions referencing Cursor rules |
| 62 | + |
| 63 | +## generate-test-ticket |
| 64 | + |
| 65 | +### Purpose |
| 66 | +Generates complete Linear ticket content for creating unit tests for dynamic adapters. The Go implementation provides better maintainability, type safety, and cross-platform compatibility. |
| 67 | + |
| 68 | +### Usage |
| 69 | +```bash |
| 70 | +# Run directly with go run |
| 71 | +go run generate-test-ticket-cmd/main.go [--verbose|-v] <adapter-name> |
| 72 | + |
| 73 | +# Or build and run |
| 74 | +./build.sh |
| 75 | +./generate-test-ticket [--verbose|-v] <adapter-name> |
| 76 | + |
| 77 | +# Build for specific platform |
| 78 | +./build.sh linux/amd64 |
| 79 | +./build.sh darwin/arm64 |
| 80 | + |
| 81 | +# Build specific tool only |
| 82 | +./build.sh "" generate-test-ticket |
| 83 | +./build.sh linux/amd64 generate-test-ticket |
| 84 | +``` |
| 85 | + |
| 86 | +### Examples |
| 87 | +```bash |
| 88 | +# Generate ticket for compute global forwarding rule (quiet mode) |
| 89 | +go run generate-test-ticket-cmd/main.go compute-global-forwarding-rule |
| 90 | + |
| 91 | +# Generate ticket with verbose output (shows description) |
| 92 | +go run generate-test-ticket-cmd/main.go --verbose compute-global-forwarding-rule |
| 93 | + |
| 94 | +# Short form of verbose flag |
| 95 | +go run generate-test-ticket-cmd/main.go -v compute-global-address |
| 96 | +``` |
| 97 | + |
| 98 | +### What it does |
| 99 | +1. **Extract adapter information** from the adapter file in `../adapters/` |
| 100 | +2. **Determine protobuf types** based on adapter name patterns |
| 101 | +3. **Extract blast propagation** configuration from the adapter |
| 102 | +4. **Generate a Linear URL** with basic fields pre-filled: |
| 103 | + - Title: "Write unit test for {adapter-name} dynamic adapter" |
| 104 | + - Assignee: Cursor Agent |
| 105 | + - Project: GCP Source Improvements |
| 106 | + - Cycle: This |
| 107 | + - Size: Small (2 points) |
| 108 | + - Status: Todo |
| 109 | + - Milestone: Quality Improvements |
| 110 | +5. **Copy description to clipboard** and optionally print it |
| 111 | + |
| 112 | +### Output |
| 113 | +The tool generates a Linear URL with basic fields and copies the description to clipboard. In verbose mode (`--verbose` or `-v`), it also prints the complete description for review. |
| 114 | + |
| 115 | +### Requirements |
| 116 | +- Must be run from the `prompter` directory |
| 117 | +- Adapter file must exist in `../adapters/` |
| 118 | +- Adapter file must contain valid SDP item type and blast propagation configuration |
| 119 | +- Go 1.19+ required |
| 120 | + |
| 121 | +## Integration with Cursor Agents |
| 122 | + |
| 123 | +The generated tickets work seamlessly with: |
| 124 | +- **Cursor rules** in `../adapters/.cursor/rules/dynamic-adapter-testing.md` |
| 125 | +- **Existing test patterns** from `../adapters/compute-global-address_test.go` |
| 126 | +- **Comprehensive testing requirements** for Get, List, and Search functionality |
| 127 | + |
| 128 | +## Workflow |
| 129 | + |
| 130 | +### Creating New Adapters |
| 131 | + |
| 132 | +#### Quick Mode (default) |
| 133 | +1. **Generate Linear URL** using `generate-adapter-ticket` |
| 134 | +2. **Click the URL** to create a new Linear issue with basic fields pre-filled |
| 135 | +3. **Paste the description** (already copied to clipboard) into the issue |
| 136 | +4. **Save the issue** - it's ready for implementation |
| 137 | + |
| 138 | +#### Review Mode (verbose) |
| 139 | +1. **Generate Linear URL** using `generate-adapter-ticket --verbose` |
| 140 | +2. **Review the description** printed in the output |
| 141 | +3. **Click the URL** to create a new Linear issue with basic fields pre-filled |
| 142 | +4. **Paste the description** (already copied to clipboard) into the issue |
| 143 | +5. **Save the issue** - it's ready for implementation |
| 144 | + |
| 145 | +### Creating Tests for Existing Adapters |
| 146 | + |
| 147 | +#### Quick Mode (default) |
| 148 | +1. **Generate Linear URL** using `generate-test-ticket` |
| 149 | +2. **Click the URL** to create a new Linear issue with basic fields pre-filled |
| 150 | +3. **Paste the description** (already copied to clipboard) into the issue |
| 151 | +4. **Save the issue** - it's already assigned to Cursor Agent |
| 152 | + |
| 153 | +#### Review Mode (verbose) |
| 154 | +1. **Generate Linear URL** using `generate-test-ticket --verbose` or `-v` flag |
| 155 | +2. **Review the description** printed in the output |
| 156 | +3. **Click the URL** to create a new Linear issue with basic fields pre-filled |
| 157 | +4. **Paste the description** (already copied to clipboard) into the issue |
| 158 | +5. **Save the issue** - it's already assigned to Cursor Agent |
| 159 | + |
| 160 | +### Cursor Agent Execution |
| 161 | +When a Cursor agent picks up the ticket: |
| 162 | +1. It will automatically apply the rules from `../adapters/.cursor/rules/dynamic-adapter-testing.md` |
| 163 | +2. Follow the comprehensive testing patterns |
| 164 | +3. Create the test file with proper structure |
| 165 | +4. Include all required test cases (Get, List, Search if supported) |
| 166 | +5. Add proper blast propagation tests |
| 167 | + |
| 168 | +## Example Ticket Content |
| 169 | + |
| 170 | +For `compute-global-forwarding-rule`: |
| 171 | + |
| 172 | +**Title**: `Write unit test for compute-global-forwarding-rule dynamic adapter` |
| 173 | + |
| 174 | +**Key Details**: |
| 175 | +- **SDP Item Type**: `gcpshared.ComputeGlobalForwardingRule` |
| 176 | +- **Protobuf Types**: `computepb.ForwardingRule` and `computepb.ForwardingRuleList` |
| 177 | +- **API Endpoints**: |
| 178 | + - GET: `https://compute.googleapis.com/compute/v1/projects/{project}/global/forwardingRules/{forwardingRule}` |
| 179 | + - LIST: `https://compute.googleapis.com/compute/v1/projects/{project}/global/forwardingRules` |
| 180 | +- **Blast Propagation**: network (InOnly), subnetwork (InOnly), IPAddress (BothWays), backendService (BothWays) |
| 181 | + |
| 182 | +## Benefits |
| 183 | + |
| 184 | +1. **Consistency**: All tests follow the same patterns and structure |
| 185 | +2. **Completeness**: Comprehensive coverage of Get, List, and Search functionality |
| 186 | +3. **Automation**: Cursor agents can automatically generate high-quality tests |
| 187 | +4. **Documentation**: Clear requirements and acceptance criteria |
| 188 | +5. **Maintainability**: Standardized approach makes tests easier to maintain |
| 189 | + |
| 190 | +## Adding New Adapters |
| 191 | + |
| 192 | +### Complete Workflow for New Adapters |
| 193 | + |
| 194 | +#### Step 1: Create Implementation Ticket |
| 195 | +1. Run `go run generate-adapter-ticket-cmd/main.go -name my-new-adapter -api-ref "https://api-reference-url"` |
| 196 | +2. Click the generated URL to create Linear issue with pre-filled fields |
| 197 | +3. Paste the description (copied to clipboard) into the issue |
| 198 | +4. Save the issue - it's ready for implementation |
| 199 | + |
| 200 | +#### Step 2: Implement the Adapter |
| 201 | +The Cursor agent (or developer) will: |
| 202 | +1. Follow the rules in `../adapters/.cursor/rules/dynamic-adapter-creation.md` |
| 203 | +2. Create the adapter file (e.g., `my-new-adapter.go`) |
| 204 | +3. Add any necessary SDP item types to `../shared/item-types.go` and `../shared/models.go` |
| 205 | + |
| 206 | +#### Step 3: Create Test Ticket |
| 207 | +1. Run `go run generate-test-ticket-cmd/main.go my-new-adapter` to generate test ticket content |
| 208 | +2. Click the generated URL to create Linear issue with pre-filled fields |
| 209 | +3. Paste the description (copied to clipboard) into the issue |
| 210 | +4. Save the issue - it's already assigned to Cursor Agent |
| 211 | + |
| 212 | +### Quick Testing for Existing Adapters |
| 213 | + |
| 214 | +When you just need tests for an existing adapter: |
| 215 | +1. Run `go run generate-test-ticket-cmd/main.go existing-adapter-name` |
| 216 | +2. Click the generated URL to create Linear issue with pre-filled fields |
| 217 | +3. Paste the description (copied to clipboard) into the issue |
| 218 | +4. Save the issue - it's already assigned to Cursor Agent |
| 219 | + |
| 220 | +## Rules Application |
| 221 | + |
| 222 | +### For Adapter Creation |
| 223 | +The `../adapters/.cursor/rules/dynamic-adapter-creation.md` file ensures that: |
| 224 | +- Proper adapter structure and patterns are followed |
| 225 | +- Correct SDP item types and metadata are defined |
| 226 | +- Appropriate blast propagation is configured |
| 227 | +- Terraform mappings are included when applicable |
| 228 | +- IAM permissions are properly defined |
| 229 | + |
| 230 | +### For Test Creation |
| 231 | +The `../adapters/.cursor/rules/dynamic-adapter-testing.md` file ensures that: |
| 232 | +- All tests use the correct package (`adapters_test`) |
| 233 | +- Proper imports are included |
| 234 | +- Correct protobuf types are used |
| 235 | +- Comprehensive test coverage is provided |
| 236 | +- Static tests with blast propagation are included |
| 237 | +- Common mistakes are avoided |
| 238 | + |
| 239 | +This ensures consistent, high-quality implementations and unit tests for all dynamic adapters. |
| 240 | + |
| 241 | +## Quick Reference |
| 242 | + |
| 243 | +### Building Tools |
| 244 | +```bash |
| 245 | +# Build both tools for current platform |
| 246 | +./build.sh |
| 247 | + |
| 248 | +# Build for specific platform |
| 249 | +./build.sh linux/amd64 |
| 250 | + |
| 251 | +# Build specific tool only |
| 252 | +./build.sh "" generate-adapter-ticket |
| 253 | +./build.sh "" generate-test-ticket |
| 254 | +``` |
| 255 | + |
| 256 | +### Creating New Adapter |
| 257 | +```bash |
| 258 | +# Generate implementation ticket |
| 259 | +go run generate-adapter-ticket-cmd/main.go -name my-adapter -api-ref "https://api-url" |
| 260 | + |
| 261 | +# After implementation, generate test ticket |
| 262 | +go run generate-test-ticket-cmd/main.go my-adapter |
| 263 | +``` |
| 264 | + |
| 265 | +### Testing Existing Adapter |
| 266 | +```bash |
| 267 | +# Generate test ticket |
| 268 | +go run generate-test-ticket-cmd/main.go existing-adapter-name |
| 269 | +``` |
| 270 | + |
| 271 | +Both tools support `--verbose` flag to preview the description before creating tickets. |
0 commit comments