Add GitHub Models as an AI provider for intent evaluation#3
Conversation
Extract shared prompt-building and response-parsing logic into pkg/ai/prompt so both Claude and Copilot providers reuse the same code. Add internal/copilot package implementing pkg/ai.Client via the OpenAI-compatible Copilot chat completions API. Update main.go to support GORT_AI_PROVIDER env var for selecting between "claude" (default) and "copilot" providers. https://claude.ai/code/session_01PQkbNNyPpMiKE7ULAqTkhY
The Copilot Chat API (api.githubcopilot.com) is not a public API and requires a special token flow only available to IDE extensions. Replace with the official GitHub Models inference API (models.github.ai) which supports server-side use with a standard GitHub PAT (models:read scope). Changes: - Rename internal/copilot -> internal/ghmodels - Endpoint: /inference/chat/completions (not /chat/completions) - Add required headers: Accept, X-GitHub-Api-Version - Default model: openai/gpt-4.1 (vendor-prefixed) - Env vars: GORT_AI_PROVIDER=github-models, GORT_GITHUB_MODELS_TOKEN, GORT_GITHUB_MODELS_MODEL https://claude.ai/code/session_01PQkbNNyPpMiKE7ULAqTkhY
Fix import ordering and struct field alignment to pass gofmt checks. Created with assistance from Claude 🤖 <claude@anthropic.com> Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
==========================================
+ Coverage 51.25% 53.30% +2.05%
==========================================
Files 10 12 +2
Lines 880 998 +118
==========================================
+ Hits 451 532 +81
- Misses 381 408 +27
- Partials 48 58 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new AI provider (GitHub Models) for intent evaluation and refactors prompt construction/response parsing so multiple providers share the same logic.
Changes:
- Introduce
pkg/ai/promptfor shared prompt-building and response-parsing functions, with unit tests. - Add
internal/ghmodelsimplementingai.Clientvia the GitHub Models chat completions API, with tests. - Update Claude provider and the main binary wiring to use the shared prompt package and select provider via
GORT_AI_PROVIDER.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/ai/prompt/prompt.go | New shared prompt builders and response parsers used by all AI providers |
| pkg/ai/prompt/prompt_test.go | Tests covering prompt construction and basic parsing cases |
| internal/ghmodels/client.go | New GitHub Models-backed ai.Client implementation |
| internal/ghmodels/client_test.go | HTTP-level tests verifying headers, endpoint, and basic success/error flows |
| internal/claudeai/client.go | Refactor to use shared prompt parsing/building functions |
| cmd/gort/main.go | Provider selection and config wiring for claude vs github-models |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactor ParseAnalysisResponse and ParseIntentResponse to use inFilesSection/expectingPath state flags instead of matching file extensions. This correctly handles any file type (not just .yaml/.md). Also add EOF flush for in-progress file blocks when trailing --- delimiter is missing. Addresses Copilot review feedback. Created with assistance from Claude 🤖 <claude@anthropic.com> Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use trimmed line values for all header detection (SUMMARY, FIX_PLAN, FILES, INTENT_MET, ISSUES) in both parsers for consistency and robustness. Skip --- delimiter lines when expecting a file path. Addresses Copilot review feedback round 2. Created with assistance from Claude 🤖 <claude@anthropic.com> Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move inFile content accumulation before header detection in both parsers so that header-like prefixes (SUMMARY:, FIX_PLAN:, etc.) inside proposed file content are preserved verbatim instead of being misinterpreted as parser headers. Add regression tests. Addresses Copilot review feedback round 3. Created with assistance from Claude 🤖 <claude@anthropic.com> Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Verify POST method, and check request body contains required JSON fields (model, messages, max_tokens) in the httptest server handler. Addresses Copilot review feedback round 4. Created with assistance from Claude 🤖 <claude@anthropic.com> Signed-off-by: Christopher Collins <collins.christopher@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@clcollins PR #3 has been fully qualified. Qualification Summary:
Intent validation: The PR still fulfills its original intent — adding GitHub Models as an AI provider for intent evaluation with shared prompt logic. All changes made during qualification (parser robustness improvements, test assertions) are bug fixes and improvements to the code introduced by this PR. No functional drift from the original purpose. Commits added during qualification:
This PR is ready to merge. Qualified by Claude on behalf of @clcollins |
Summary
pkg/ai/prompt/so both providers share identical prompts and parse logicinternal/ghmodels/implementingai.Clientvia the GitHub Models inference API (models.github.ai), with proper auth headers and vendor-prefixed model namesinternal/claudeai/to use the shared prompt packagecmd/gort/main.goviaGORT_AI_PROVIDER=github-modelsConfiguration
GORT_AI_PROVIDERclaude"claude"or"github-models"GORT_GITHUB_MODELS_TOKENGORT_GITHUB_TOKENmodels:readscopeGORT_GITHUB_MODELS_MODELopenai/gpt-4.1Test plan
go buildcompiles all changed packagesgo test ./internal/ghmodels/... ./internal/claudeai/... ./pkg/ai/prompt/...passesgo vetclean on all changed packagesGORT_AI_PROVIDER=github-modelsand verify intent evaluation on a real push eventhttps://claude.ai/code/session_01PQkbNNyPpMiKE7ULAqTkhY