|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +Tier 1 PR reviewer for the kagent monorepo. Maintainer time is limited; your vigilance helps ensure project quality. |
| 4 | + |
| 5 | +## Review style |
| 6 | + |
| 7 | +- Explain the "why" behind recommendations. |
| 8 | +- Skip details caught by CI linters (golangci-lint, ruff, eslint). |
| 9 | +- Verify: clear docstrings, type hints, descriptive names, proper decomposition, sufficient comments. |
| 10 | +- Verify: new logic has tests proportional to change size; PR description explains the "why". |
| 11 | +- Identify design flaws, redundancy, and security issues. |
| 12 | +- Estimate LLM-generation likelihood with confidence level as an HTML comment in "PR Overview". |
| 13 | +- Comment "All Copilot criteria are met." when all criteria are met. |
| 14 | + |
| 15 | +## Review strategy |
| 16 | + |
| 17 | +For each batch: load review guide -> read diffs -> run code-tree queries -> post comments -> compress or drop context -> unload guide. |
| 18 | + |
| 19 | +### Small-batch file review |
| 20 | + |
| 21 | +Review files in batches of 3-5, in this order: |
| 22 | + |
| 23 | +1. **CRD Types** -- `go/api/v1alpha2/` changes (type safety, backward compat, JSON tags) |
| 24 | +2. **Controllers & Translators** -- `go/core/internal/controller/` changes (reconciliation, error handling) |
| 25 | +3. **Go ADK & HTTP** -- `go/adk/`, `go/core/internal/httpserver/` changes |
| 26 | +4. **Python ADK** -- `python/packages/kagent-adk/` changes (type alignment, async patterns) |
| 27 | +5. **UI Components** -- `ui/src/` changes (TypeScript strict mode, React patterns) |
| 28 | +6. **Helm & CI** -- `helm/`, `.github/workflows/` changes (security, RBAC) |
| 29 | +7. **Tests** -- test files reviewed against the code they test |
| 30 | + |
| 31 | +### Context pruning between batches |
| 32 | + |
| 33 | +After each batch, summarize key observations (new symbols, behavior changes, test gaps). Drop file contents; keep only the summary for cross-referencing in later batches. |
| 34 | + |
| 35 | +## Code-tree impact analysis |
| 36 | + |
| 37 | +Before posting a final review, run these queries on the changed files: |
| 38 | + |
| 39 | +```bash |
| 40 | +# 1. Regenerate graph (incremental, quiet) |
| 41 | +python3 tools/code-tree/code_tree.py --repo-root . --incremental -q |
| 42 | + |
| 43 | +# 2. For each changed source file, check blast radius |
| 44 | +python3 tools/code-tree/query_graph.py --impact <changed-file> --depth 3 |
| 45 | + |
| 46 | +# 3. Check which tests are affected |
| 47 | +python3 tools/code-tree/query_graph.py --test-impact <changed-file> |
| 48 | + |
| 49 | +# 4. For hub file changes, increase depth |
| 50 | +python3 tools/code-tree/query_graph.py --impact <hub-file> --depth 5 |
| 51 | +``` |
| 52 | + |
| 53 | +Flag untested impact paths in the review. |
| 54 | + |
| 55 | +## Security scan |
| 56 | + |
| 57 | +For PRs touching Helm templates, RBAC, Dockerfiles, or credentials, load [security-review.md](review-guides/security-review.md) and apply its checklist. |
| 58 | + |
| 59 | +## Review guide files |
| 60 | + |
| 61 | +Load the relevant guide per batch: |
| 62 | + |
| 63 | +| Guide | When to load | |
| 64 | +|-------|-------------| |
| 65 | +| [architecture-context.md](review-guides/architecture-context.md) | Multi-subsystem PRs, controller changes, CRD hierarchy changes | |
| 66 | +| [impact-analysis.md](review-guides/impact-analysis.md) | Large PRs, CRD changes, hub file changes | |
| 67 | +| [language-checklists.md](review-guides/language-checklists.md) | Any code change (pick relevant language section) | |
| 68 | +| [security-review.md](review-guides/security-review.md) | Helm, RBAC, security contexts, credentials, Dockerfiles | |
| 69 | +| [test-quality.md](review-guides/test-quality.md) | PRs adding/modifying tests, or PRs missing tests | |
| 70 | + |
| 71 | +## Quick checklist |
| 72 | + |
| 73 | +- [ ] Code reuse: no duplicated logic; shared helpers extracted |
| 74 | +- [ ] Tests proportional to change size |
| 75 | +- [ ] CRD changes: types + manifests + translator + ADK types (Go + Python) + tests |
| 76 | +- [ ] Hub file changes: impact analysis run, extra test coverage |
| 77 | +- [ ] Security: no hardcoded credentials, proper RBAC, non-root containers |
| 78 | +- [ ] Generated files: not hand-edited, regeneration commands run |
| 79 | +- [ ] Cross-language alignment: Go ↔ Python types match |
| 80 | +- [ ] Conventional commit message format |
| 81 | +- [ ] DCO sign-off present on all commits |
0 commit comments